C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

template et taille d'un buffer de char

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French)
View previous topic :: View next topic  
Author Message
phil
Guest





PostPosted: Tue Apr 26, 2005 7:39 pm    Post subject: template et taille d'un buffer de char Reply with quote



Bonjour,

J'essai d'encapsuler une structure C, qui a une taille prédéfinie.
Je dois définir un char buffer[Une Taille] (un new est impossible).
Je voudrais définir 'Une Taille' à la déclaration, je croyais donc
pouvoir faire :

template <typename MAX_SIZE>
class toto
{
public:
struct msgbuf
{
char buffer[MAX_SIZE];
};
};

Mais j'obtiens l'erreur : error: syntax error before `]' token

Le but final était de pouvoir faire :
toto<255> t;
pour obtenir un équivalent de
class toto
{
public:
struct msgbuf
{
char buffer[255];
};
};

Je vois bien une solution avec les macros, mais n'y aurait il pas une
autre solution ?

Merci.
--
Philippe Leroux
Back to top
Vincent Lascaux
Guest





PostPosted: Tue Apr 26, 2005 7:43 pm    Post subject: Re: template et taille d'un buffer de char Reply with quote



Quote:
template <typename MAX_SIZE

Ici tu indique que MAX_SIZE sera une classe.
Remplace la ligne par

template
--
Vincent



Back to top
phil
Guest





PostPosted: Wed Apr 27, 2005 6:14 pm    Post subject: Re: template et taille d'un buffer de char Reply with quote



Vincent Lascaux a écrit :
Quote:
template

Ici tu indique que MAX_SIZE sera une classe.
Remplace la ligne par

template
Merci beaucoup.


--
Philippe Leroux

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.