How to use STL in VC++?

K

Kelvin

To all,

I've tried to use the data structures in STL of standard
C++ lib, but compile errors such as "vector is an
undefined variable/type"

here's the snippet

#include <vector.h>
.... other include file(s)

int t_main () {
vector<int> vInt;
vInt.push_back(100);
vInt.push_back(20);
.... other push_back statements...

return 0;
}

It seems to me that VC++ compiler can't identify most the
C++ identifiers such as cout, cin.

Can anyone help on this issue??? Or are there any useful
tutorials on introducing how to code under VC++???

Thx!
 
C

Carl Daniel [VC++ MVP]

Kelvin said:
To all,

I've tried to use the data structures in STL of standard
C++ lib, but compile errors such as "vector is an
undefined variable/type"

here's the snippet

#include <vector.h>

There's no such include file. Perhaps you mean said:
... other include file(s)

int t_main () {
vector<int> vInt;

vector is in the std namespace, perhaps you mean std::vector? (Or you might
want to put using namespace std; after your #includes).
vInt.push_back(100);
vInt.push_back(20);
.... other push_back statements...

return 0;
}

It seems to me that VC++ compiler can't identify most the
C++ identifiers such as cout, cin.

Can anyone help on this issue??? Or are there any useful
tutorials on introducing how to code under VC++???

This is just standard C++. Get an up to date C++ book and you shouldn't
have any problems (especially if you're using the latest version of VC++ -
version 7.1 aka Visual C++ .NET 2003).

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top