Strange error with std::vector

C

Cristiano

When I compile this code:

std::vector <char*> TSTrow[TESTnum];
....
char *tmp=new char[32]; sprintf(tmp, ...);
TSTrow[(int)lpParam].push_back(tmp);

I get this error:
"E2316 'push_back' is not a member of 'std::vector<char
*,std::allocator<char *> >'"

but 'push_back' *is* a member of std::vector! Does it make any sense?

When I use VC++ 2005 Express Edition I don't get any error.
Could somebody help me?

Thanks
Cristiano
 
V

Victor Bazarov

Cristiano said:
When I compile this code:

std::vector <char*> TSTrow[TESTnum];

That's an array of vectors to pointers to char.
...
char *tmp=new char[32]; sprintf(tmp, ...);
TSTrow[(int)lpParam].push_back(tmp);

I get this error:
"E2316 'push_back' is not a member of 'std::vector<char
*,std::allocator<char *> >'"

but 'push_back' *is* a member of std::vector! Does it make any sense?

If the compiler doesn't know what that class (the instantiation of
the 'std::vector' template for 'char*') has as members, it will not
let you use any expression after the dot.
When I use VC++ 2005 Express Edition I don't get any error.
Could somebody help me?

Are you sure you've included the necessary headers? It is likely
that VC++ includes the missing header behind the scenes, but you
shouldn't rely on that.

Next time, please follow the recommendations of FAQ 5.8

V
 
C

Cristiano

Victor said:
Are you sure you've included the necessary headers? It is likely
that VC++ includes the missing header behind the scenes, but you
shouldn't rely on that.

Next time, please follow the recommendations of FAQ 5.8

Where are the FAQ?

Cristiano
 

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,774
Messages
2,569,599
Members
45,167
Latest member
SusanaSwan
Top