Why am I getting error C2061 identifier 'vector'

In one of my old projects I use vectors and simply needed to use include like this:

#include <vector>

Now i'm trying to insert my old code into someone else's project which likely is a different type of project (not sure which or how to find out).  While both projects are in C++ my old code that uses vectors now generates this error C2061: syntax error : identifier 'vector' in his project.

How do I get rid of this?  Thanks.

LVL 1
shaolinfunkAsked:
Who is Participating?
 
evilrixSenior Software Engineer (Avast)Commented:
did you need to add "using namespace std;" at the top of the .cpp file maybe?

or, prefix vector with std::
0
 
shaolinfunkAuthor Commented:
weird..putting using namespace std generates more errors...why is that?

but prefixing vector with std:: does the trick.
0
 
shaolinfunkAuthor Commented:
thanks for fast response evil!
0
 
evilrixSenior Software Engineer (Avast)Commented:
>> weird..putting using namespace std generates more errors...why is that?
It imports the std namespace into the current one. If you have other symbols with names that clash with those in the std namespace you'll get errors.

>> but prefixing vector with std:: does the trick.
What would have been my preferred solutions. I never import the std namespace, I always use fully qualified names for standard library items.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.