Re: [Algorithms] C++ inherited constructors
Brought to you by:
vexxed72
From: Matt A. <de...@gm...> - 2000-07-15 11:18:45
|
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 |