Re: [Algorithms] C++ inherited constructors
Brought to you by:
vexxed72
|
From: Michael H. <he...@po...> - 2000-07-15 10:54:17
|
Make class A's default constructor do nothing, and make a second one
that takes a useless argument. You can do it like this:
class A {
protected:
A() {} // B can call this, but users will get warnings if
they use it
public:
A(bool x);
};
class B: public A {
public:
B(); // calls A(), which does nothing
};
mike
----- Original Message -----
From: "Matt Adams" <de...@gm...>
To: <gda...@li...>
Sent: Saturday, July 15, 2000 3:22 AM
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
>
>
|