Re: [Algorithms] C++ inherited constructors
Brought to you by:
vexxed72
|
From: Michael H. <he...@po...> - 2000-07-16 08:46:23
|
You can't call virtual functions from constructors. Doing so is
undefined in C++. (MSVC will call the local instantiation, even when
there's an overloaded one, for instance.)
mike
----- Original Message -----
From: "Aaron Drew" <ri...@ho...>
To: <gda...@li...>
Sent: Sunday, July 16, 2000 12:41 AM
Subject: RE: [Algorithms] C++ inherited constructors
> Why not have your base class constructor call a virtual private
member
> function and overload that function in the derived class?
>
> > -----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
>
>
|