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 

Re: Pb de Classes dérivées

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





PostPosted: Fri Aug 29, 2003 12:54 pm    Post subject: Re: Pb de Classes dérivées Reply with quote



Le Vendredi 29 Août 2003 14:37, Fred D. a écrit :

Quote:
Bonjour,

Je souhaite utiliser un pointeur pouvant pointer sur trois classes
différentes , elles - mêmes dérivées d'une classe de base :


class CControlA : public CControl
{
public:
virtual int Init();
};
class CControlB : public CControl
{
public:
int Init();
};
class CControlC : public CControl
{
public:
int Init();
};

[...]

m_pControl ->Init() doit appeler la fonction Init() de la classe choisie.
D'abord est-possible ? si oui, comment déclarer m_pControl ?

Oui, ça s'appelle le polymorphisme d'héritage. Il suffit de déclarer Init()
en fonction virtuelle dans la classe de base "CControl" :


class CControl
{
// ...
virtual int Init() = 0;
};


Vincent

--
SL> Au fait elle est mieux ma signature maintenant ?
Oui. T'enlève encore les conneries que t'as écrit dedans et c'est bon.
-+- JB in <http://www.le-gnu.net> : Le neuneuttoyage par le vide -+-

Back to top
Fred D.
Guest





PostPosted: Fri Aug 29, 2003 2:32 pm    Post subject: Re: Pb de Classes dérivées Reply with quote



Merci mais ce n'est pas ma question qui est : comment je déclare mon
pointeur ?

Cordialement,

Fred D.


Back to top
M.B.
Guest





PostPosted: Fri Aug 29, 2003 2:41 pm    Post subject: Re: Pb de Classes dérivées Reply with quote



CControl * m_pControl;

MB

"Fred D." <f.dulou (AT) caramail (DOT) com> a écrit dans le message news:
binnvd$h11$1 (AT) d03 (DOT) completel.fr...
Quote:
Merci mais ce n'est pas ma question qui est : comment je déclare mon
pointeur ?

Cordialement,

Fred D.





Back to top
Fred D.
Guest





PostPosted: Fri Aug 29, 2003 3:21 pm    Post subject: Re: Pb de Classes dérivées Reply with quote

Merci,

Fred D.


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.