all groups > visual c libraries > november 2003 >
You're in the

visual c libraries

group:

How to use STL under VC++


How to use STL under VC++ Kelvin
11/16/2003 5:36:45 PM
visual c libraries: 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!
Re: How to use STL under VC++ Michael Geyer
11/17/2003 8:32:07 AM

Hi!

[quoted text, click to view]
news:029f01c3acab$42d3d5b0$a401280a@phx.gbl:

It might be helpful if to provide your name and email-address...

[quoted text, click to view]

Shouldn't it read

#include <vector>
?

[quoted text, click to view]

For me, I have no problems using STL in MSVC (I used VC6 and am now using
..NET). In Visual Studio.NET, you should start with e.g. a C++ Win32-
Project to make sure the correct libraries are linked.

Best wishes,

How to use STL under VC++ Mark
12/7/2003 12:31:21 AM
Hello,
The reason that your code does not work is as follows:
You need to include the new vector definition (#include
<vector>)
to use the cout, and cin you must include <iostream> also
at the beginning of your program you must link to the std
namespace or fully qualify all of your references.
#using namespace std;

or

std::cout<<"Test string"<<std::endl;
Mark

[quoted text, click to view]
AddThis Social Bookmark Button