-
Using STL List
When I compile this code.
Code:
#include <list>
main() {
list <int> numlist;
}
I get an error, "list is undeclared identifier".
All the examples of using the list show this to be correct, do I need to download or update my copy of STL or something? Or are there other headers I must include?
Im using MSVC 6 with SP5
Any feedback is appreciated.
-
try this:
Code:
#include <list>
main() {
std::list <int> numlist;
}
I usually typdef anything vectors, list and thing which hide in namespace std;
-
or you could do this:
Code:
#include<list>
using std::list;
int main()
{ list<int> numList;
return(0);
}
or even:
Code:
#include<list>
using namespace std;
int main()
{ list<int> numList;
return(0);
}
those two methods or endo's are all acceptable, your choice just depends on your preference, i personally get sick of doing std::list, std::string, std::vector and the sort so normally just use a using std::.... .