Page 1 of 1

STL

Posted: Fri Aug 22, 2003 8:47 am
by katundu
I am having a hard time finding a compiler where STL works. It seems that it is not as standard as it should be. My gcc compiler (ver 3.x.x) does not accept this code, it complains about the vector declaration in the main program and not the library declaration.

#include<iostream>
#include<vector>

main(){
vector<int> vect;
}

Any thoughts concerning this situation would be appreciated.

Posted: Fri Aug 22, 2003 8:53 am
by Per
The vector class is declared in another namespace (namely the std namespace), so you must either write "using namespace std;" somewhere, or use the form "std::vector<int>".

(Hint: there is a C++ forum, where topics like this are not off-topic)

Posted: Sun Aug 24, 2003 6:20 pm
by Krzysztof Duleba
It's enough to write
[cpp]using namespace vector;[/cpp]
In some (rare) cases using namespace std can couse some troubles.