Re: [Algorithms] C++ inherited constructors
Brought to you by:
vexxed72
From: Jim O. <j.o...@in...> - 2000-07-16 09:35:28
|
> Why not have your base class constructor call a virtual private member > function and overload that function in the derived class? I wouldn't rely on such a thing - vtable's tend to have a nasty habbit of not being properly initialized in the constructor and desctructor. I once spend far to much time hunting a bug which turned out to be a pure virtual call in one of my inline destructors... I'd either stick to Adam's good advise, or use the protected constructor trick (note that this doesn't have to be the default constructor... I use a Thread::Thread(bool doNotInitialize) internally). Jim Offerman Innovade - designing the designer ----- Original Message ----- From: "Aaron Drew" <ri...@ho...> To: <gda...@li...> Sent: Sunday, July 16, 2000 9:41 AM Subject: RE: [Algorithms] C++ inherited constructors > > > -----Original Message----- > > From: gda...@li... > > [mailto:gda...@li...]On Behalf Of Matt > > Adams > > Sent: Saturday, July 15, 2000 9:19 PM > > To: gda...@li... > > Subject: Re: [Algorithms] C++ inherited constructors > > > > > > > > I need this for aesthetic reasons :) > > I've got an abstract CThread class. If a want to create a new thread, I > > build my process class and inherit CThread, which creates a new thread by > > construction. > > Now I want my main-threadloop-class to inherit CThread, too, to > > provide all > > the thread functionality to my main thread. But that thread already exists > > created by compiler ), and shouldn't be created again by CThread. > > Of course I can put CThread () and ~CThread () in functions like Create() > > and Destroy() and leave the constructor / destructor empty. But it'd be > > nicer if it could be done in another way... > > > > ----- Original Message ----- > > From: Favnir > > To: gda...@li... > > Sent: Saturday, July 15, 2000 1:32 PM > > Subject: Re: [Algorithms] C++ inherited constructors > > > > The only way you can do this is to define a (preferably) protected > > do-nothing constructor for the base class, and inherit it in the subclass > > constructor. > > > > But, why in the world would you need to do this, in the first place? > > > > Are, > > F > > > > ----- Original Message ----- > > From: Matt Adams > > To: gda...@li... > > Sent: Saturday, July 15, 2000 12:22 PM > > Subject: [Algorithms] C++ inherited constructors > > > > > > Hi, > > > > I got a question about the C++ class hierarchy. > > > > class a > > { > > a () {...}; // constr a > > }; > > > > class b : a > > { > > b () {...}; // constr b > > }; > > > > b instance; > > > > When creating an instance of b, constructors for both class a and class b > > are called. > > Is there a way to suppress the automatic calling of constructor a ? > > Or something like 'overloading' the old constructor by a new one ? > > I couldn't find anything like that in the compiler docs. > > > > Any help appreciated, > > Matt > > > > > > _______________________________________________ > > GDAlgorithms-list mailing list > > GDA...@li... > > http://lists.sourceforge.net/mailman/listinfo/gdalgorithms-list > > > > > > _______________________________________________ > > GDAlgorithms-list mailing list > > GDA...@li... > > http://lists.sourceforge.net/mailman/listinfo/gdalgorithms-list > > > > > _______________________________________________ > GDAlgorithms-list mailing list > GDA...@li... > http://lists.sourceforge.net/mailman/listinfo/gdalgorithms-list > |