Re: [Algorithms] C++ inherited constructors
Brought to you by:
vexxed72
From: Will P. <wi...@cs...> - 2000-07-15 19:52:58
|
I don't completely understand your problem, but it might be solvable by using containment rather than inheritance, i.e. a process *has* a thread rather than *is* a thread. I think it would allow for the semantics you want. You could pass in an external thread for the process/main loop to "have" through a constructor argument, or you could just have the process/main loop create a thread through it's default argumentless constructor. The same goes with your main loop class: it has a thread, not is a thread. It's an idea, anyway. :) Will ---- Will Portnoy http://www.cs.washington.edu/homes/will On Sat, 15 Jul 2000, Matt Adams wrote: > 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 > |