Error: a class qualified name is not allowed

c++, using-declaration, visual-c++

Solution

You can't bring a name from the class scope into namespace scope with `using` directive. You can only be `using` a name defined at namespace scope, in a different namespace.

Problem

I'm getting an error at line `using std::list<int>::iterator`. The compiler gives the error `Error: a class-qualified name is not allowed.` I am unsure what is the problem? Can someone expand on the compilers problem with my code. ``` #include <iostream> #include <list> using std::cout; using std::endl; using std::list; using std::list<int>::iterator; int main( ) { list<int> listObject; for (int i = 1; i <= 3; i++) listObject.push_back(i); cout << "List contains:\n"; iterator iter; for (iter = listObject.begin( ); iter != listObject.end( ); iter++) cout << *iter << " "; cout << endl; cout << "Setting all entries to 0:\n"; for (iter = listObject.begin( ); iter != listObject.end( ); iter++) *iter = 0; cout << "List now contains:\n"; for (iter = listObject.begin( ); iter != listObject.end( ); iter++) cout << *iter << " "; cout << endl; return 0; } ```

Original source