Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: a class qualified name is not allowed

Tags:

visual-c++

In line using std::list::iterator the compiler gives an message "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;
 }
like image 729
user2364556 Avatar asked Apr 22 '14 19:04

user2364556


1 Answers

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.

like image 76
Igor Tandetnik Avatar answered Oct 12 '22 10:10

Igor Tandetnik