j*****k 发帖数: 1198 | 1 template
void lstack::print(ostream& os)
{
if(data==NULL) return;
vector::iterator i; // error: expected `;' before ‘i’
for(i=data->begin(); iend();i++) //error: ‘i’ was not
declared in this scope
os<
os<
return;
};
大家帮忙看看,这两个错误怎么回事?不解。用的是gcc version 4.1.3 20070929 |
t****t 发帖数: 6806 | 2 typename vector::iterator i;
【在 j*****k 的大作中提到】 : template : void lstack::print(ostream& os) : { : if(data==NULL) return; : vector::iterator i; // error: expected `;' before ‘i’ : for(i=data->begin(); iend();i++) //error: ‘i’ was not : declared in this scope : os<: os<: return;
|
h****e 发帖数: 2125 | 3 iterator is a dependent name in 'vector', you have to explicitly bring it
into the vector's scope or fully qualify it.
【在 j*****k 的大作中提到】 : template : void lstack::print(ostream& os) : { : if(data==NULL) return; : vector::iterator i; // error: expected `;' before ‘i’ : for(i=data->begin(); iend();i++) //error: ‘i’ was not : declared in this scope : os<: os<: return;
|