Hello,
I am learning STL using G++ under Ubuntu. Today I copied following C++ code from a text book (Absolute C++) and tried to run it:
When I compile it, got following error:Code:#include <iostream> #include <vector> using std::cout; using std::endl; using std::vector; using std::vector<int>::iterator; int main() { vector<int> container; for (int i=1;i<=4;i++) container.push_back(i); cout << "Here is what is in the container:\n"; iterator p; for (p=container.begin();p!=container.end();p++) cout << *p << " "; cout << endl; }
STL_vector.cpp:6: error: ‘std::vector<int, std::allocator<int> >’ is not a namespace
So, what's the problem of: using std::vector<int>::iterator;
Sorry for this kind of newbie question. Thanks in advance for your help.
regards,
Derek
Reply With Quote



LinkBack URL
About LinkBacks



