std::vector<char> not working

I am using Visual C++ 2008 and when I use this code inside main()
 
std::vector<char>c1;


I get the following errors

1
2
3
error C2039: 'vector' : is not a member of 'std'
mymain.cpp(21) : error C2065: 'vector' : undeclared identifier
mymain.cpp(21) : error C2062: type 'char' unexpected


the first one is really puzzling me because everywhere I was sure vector was a part of std?? Does anybody know why this error is happening. I can eliminate it using #include <vector> and taking away the std:: part, but I want to use a vector in a header file.
It is a part of std. You need to include <vector> even if you use it as std::vector. The STL is composed of many many files, which is why you need to include vector for vector support.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <vector>
#include <iostream>

using namespace std;

int main()
{
        std::vector<char> cl;
        cl.push_back("h");

        vector<char> another;
        another.push_back("i");
 
        //will both do the same thing, but you have to include <vector>
}
Last edited on
okay thanks for the reply
Topic archived. No new replies allowed.