Problem with pair container typedef

T

Takeshi

Hi,

I wonder if anyone knows what I'm doing wrong. I'm trying to create a
typedef based on a pat. Here is the code snippet:

#include <utility>
#include <list>
#include <vector>

typedef pair < int, string > IdNamePair ;

.....


When I compile (VSC++) I get the following error:

adt.h(34) : error C2143: syntax error : missing ';' before '<'
adt.h(34) : error C2059: syntax error : '<'


What gives?. Anyone knows whats wrong with this piece of code?
 
J

Jeff Flinn

Takeshi said:
Hi,

I wonder if anyone knows what I'm doing wrong. I'm trying to create a
typedef based on a pat. Here is the code snippet:

#include <utility>
#include <list>
#include <vector>

typedef pair < int, string > IdNamePair ;
std::pair


....


When I compile (VSC++) I get the following error:

adt.h(34) : error C2143: syntax error : missing ';' before '<'
adt.h(34) : error C2059: syntax error : '<'


What gives?. Anyone knows whats wrong with this piece of code?

Read up on namespace. All standard libraries are in namespace std.

Jeff F
 
V

Vyacheslav Kononenko

Takeshi said:
Hi,

I wonder if anyone knows what I'm doing wrong. I'm trying to create a
typedef based on a pat. Here is the code snippet:

#include <utility>
#include <list>
#include <vector>

typedef pair < int, string > IdNamePair ;

....


When I compile (VSC++) I get the following error:

adt.h(34) : error C2143: syntax error : missing ';' before '<'
adt.h(34) : error C2059: syntax error : '<'


What gives?. Anyone knows whats wrong with this piece of code?
pair in the std namespace so it should be
typedef std::pair < int, std::string > IdNamePair;

and <string> should be included as well
 
V

Victor Bazarov

Takeshi said:
I wonder if anyone knows what I'm doing wrong. I'm trying to create a
typedef based on a pat. Here is the code snippet:

#include <utility>
#include <list>
#include <vector>

typedef pair < int, string > IdNamePair ;

Should probably be

typedef std::pair said:
....


When I compile (VSC++) I get the following error:

adt.h(34) : error C2143: syntax error : missing ';' before '<'
adt.h(34) : error C2059: syntax error : '<'


What gives?. Anyone knows whats wrong with this piece of code?

Yes, 'pair' and 'string' are types declared in the 'std' namespace.

V
 
T

Takeshi

Hi Vyacheslav Kononenko,

Many thanks i finally got it to work !. It's always the small things ;-)
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top