a question on vector declaration

J

Jee

Hi,
I wonder what's wrong with the following,

std::vector<pair<int, int>> myVec;

The compiler always complains that "expect , instead of >>".

Thanks.
 
S

Sam Holden

Hi,
I wonder what's wrong with the following,

std::vector<pair<int, int>> myVec;

The compiler always complains that "expect , instead of >>".

">>" is the right shift operator, you need to use:

std::vector<pair<int, int> > MyVec;


And std::pair would make more sense since you are suing std::vector...
 
A

Andrey Tarasevich

Jee said:
Same error after I change it to

std::vector<std::pair<int, int>> myVec;

Any idea?
...

Read Sam's reply again. He already answered your question.
 
M

Mike Wahler

Jee said:
Same error after I change it to

std::vector<std::pair<int, int>> myVec;

Any idea?

Read Sam's reply again, carefully.

std::vector<std::pair<int,int> > myVec;
^^^

-Mike
 
A

Acid_X

Same error after I change it to

std::vector<std::pair<int, int>> myVec;

Any idea?

It is very simple.
You MUST have a space between th two '>' characters at the end of the
statement. Without the space, the compiler thinks it is a shift operator.

The statement You would should look like this :

std::vector<std::pair<int, int> > my Vec ;

Note the Space between the two '>'
 

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

No members online now.

Forum statistics

Threads
474,147
Messages
2,570,833
Members
47,380
Latest member
AlinaBlevi

Latest Threads

Top