473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problem with pair container typedef

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?

Jul 22 '05 #1
4 7194
Takeshi wrote:
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

--
Regards,
Slava

Jul 22 '05 #2

"Takeshi" <do************@work.com> wrote in message
news:cl**********@hercules.btinternet.com...
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
Jul 22 '05 #3
Takeshi wrote:
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< int, std::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?


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

V
Jul 22 '05 #4
Hi Vyacheslav Kononenko,

Many thanks i finally got it to work !. It's always the small things ;-)
Vyacheslav Kononenko wrote:
Takeshi wrote:
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


Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Neil Zanella | last post by:
Hello, I would like to ask how come the design of C++ includes std::pair. First of all I don't think many programmers would use it. For starters, what the first and second members are depends...
8
by: lok | last post by:
i have a class: template <class T1, class T2> class CPairMapping { public: typedef std::pair<T1, T2> ValuePair_t; typedef std::vector<ValuePair_t> ValueList_t; typedef std::binary_function<...
4
by: Jason Heyes | last post by:
Stupid templates won't compile. Here is my program: #include <fstream> #include <iostream> #include <algorithm> #include <iterator> #include <map> using namespace std; template <class T,...
5
by: ma740988 | last post by:
For starters, Happy New Year to all!! I created a vector of pairs where pair first is a primitive and pair second is a vector of ints. So now: # include <iostream> # include <vector>
13
by: kamaraj80 | last post by:
Hi I am using the std:: map as following. typedef struct _SeatRowCols { long nSeatRow; unsigned char ucSeatLetter; }SeatRowCols; typedef struct _NetData
6
by: Bart Simpson | last post by:
I am wriing a messaging system and I need to mantain a list of subscribers(object) to topics (string). which of the ff representations is better (and why?) typedef pair<string,...
0
by: toton | last post by:
Hi, I have a complex design of some dynamic situation. First I am posting the design, then a few questions regarding the problem I am facing. Hope some of the experts will answer the questions....
7
by: aaragon | last post by:
Hi everyone, The idea is quite simple: generate a container with random values in it. For that, I decided to create a class that I called RandomContainer that inherits from a container (with...
18
by: subramanian100in | last post by:
Consider a class that has vector< pair<int, string>* c; as member data object. I need to use operator>to store values into this container object and operator<< to print the contents of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.