typedef error, #define instead?

S

sandwich_eater

The following code throws a compiler error: expected init-declarator
before '<' token


struct mystru
{
int yspace;
std::string ymonkey;
};

typedef std::vector<mystru> myvec;

I think I should use the following instead but what is the usual way to
avoid myvec being picked up somewhere else?

#define myvec std::vector<mystru>


Thanks,
Daniel
 
M

msalters

(e-mail address removed) schreef:
The following code throws a compiler error: expected init-declarator
before '<' token


struct mystru
{
int yspace;
std::string ymonkey;
};

typedef std::vector<mystru> myvec;

The compiler has to know std::vector is a template, else it won't know
that < starts the template argument list. Include <vector>.

HTH,
Michiel Salters
 

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,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top