PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.cplus > Strange error with std::vector
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Strange error with std::vector

Réponse
 
LinkBack Outils de la discussion
Vieux 15/11/2007, 14h34   #1
Cristiano
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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 me?

Thanks
Cristiano


  Réponse avec citation
Vieux 15/11/2007, 14h38   #2
Victor Bazarov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Strange error with std::vector

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 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


  Réponse avec citation
Vieux 15/11/2007, 19h38   #3
Cristiano
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Strange error with std::vector

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


  Réponse avec citation
Vieux 15/11/2007, 19h41   #4
Victor Bazarov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Strange error with std::vector

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


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 08h48.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12462 seconds with 12 queries