473,503 Members | 1,747 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strange error with std::vector

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
Nov 15 '07 #1
3 1788
Cristiano wrote:
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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 15 '07 #2
Victor Bazarov wrote:
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.
I #included <vector>, it should be enough, right?
Next time, please follow the recommendations of FAQ 5.8
Where are the FAQ?

Cristiano
Nov 15 '07 #3
Cristiano wrote:
Victor Bazarov wrote:
>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.

I #included <vector>, it should be enough, right?
>Next time, please follow the recommendations of FAQ 5.8

Where are the FAQ?
http://www.parashift.com/c++-faq-lite/

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 15 '07 #4

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

Similar topics

27
5897
by: Jason Heyes | last post by:
To my understanding, std::vector does not use reference counting to avoid the overhead of copying and initialisation. Where can I get a reference counted implementation of std::vector? Thanks.
8
1859
by: Peng | last post by:
Hi, I have encountered a simple but strange problem recently, with the STL vector. When I tried to compile a code like this, the compiler flags an error: Error 212: "small.cc", line 200 #...
7
1472
by: Hamish | last post by:
Hello, lately I've been having a lot of trouble with the std::vector. Seems to create unpredictable behaviour within my code. Example: struct Switch{ int i; int j; double d; };
20
17744
by: Anonymous | last post by:
Is there a non-brute force method of doing this? transform() looked likely but had no predefined function object. std::vector<double> src; std::vector<int> dest; ...
17
3326
by: Michael Hopkins | last post by:
Hi all I want to create a std::vector that goes from 1 to n instead of 0 to n-1. The only change this will have is in loops and when the vector returns positions of elements etc. I am calling...
32
69638
by: zl2k | last post by:
hi, c++ user Suppose I constructed a large array and put it in the std::vector in a function and now I want to return it back to where the function is called. I can do like this: ...
56
5699
by: Peter Olcott | last post by:
I am trying to refer to the same std::vector in a class by two different names, I tried a union, and I tried a reference, I can't seem to get the syntax right. Can anyone please help? Thanks
8
5354
by: Lionel B | last post by:
On my platform I find that the std::vector<boolspecialisation incurs a significant performance hit in some circumstances (when compared, say, to std::vector<intprogrammed analagously). Is it...
6
5604
by: Bobrick | last post by:
Hi. Thanks to everyone who replied to my last post, it turns out it wasn't the line where I was trying to treat the variable in question as an array which was the problem, but the line above. ...
0
7203
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
7087
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...
0
7281
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5579
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
383
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.