g++ compiler gives this error: expected `;’ before ‘it’
template <typename T>
class myList : public std::list<T>
{
public:
void foo ()
{
std::list<T>::iterator it; // compiler error as above mentioned, why ???
}
};
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In g++. whenever in a template you see the error:
suspect you need a typename:
This is needed when in a template you have a new type declared (in this case the list iterator) which is dependant on one or more of the template parameters. The need is not unique to g++ BTW, it’s part of standard C++.