Re: [Dev-C++] Derived Classes & Destructors
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Lior W. <we...@st...> - 2004-06-21 17:13:47
|
Yes, but keep in mind, that while you only have one destructor per class,
you may have any number of constructors. So while there is no doubt as to
which destructor will be called (there is only one), it is not clear
beforehand which constructor will be used. By default, the compiler will use
the "default constructor" (big surprize!), which is the one having no
arguments. If you explicitely want to use a different constructor use the
following syntax:
class B : public A {
public:
B(arg1,arg2,arg3) : A(arg1,arg2+arg3) {
// A::A(arg1,arg2+arg3) will
// be called BEFORE this
// constructor executes
// B's specific stuff goes here
};
};
greetings
lior
----- Original Message -----
From: "David McKen" <dml...@co...>
To: "Mailing List, Dev-Cpp" <dev...@li...>
Sent: Monday, June 21, 2004 5:24 PM
Subject: [Dev-C++] Derived Classes & Destructors
> If I have a class B that inherets from a class A and I create an object
> of type B (call it instance_B).
>
> when instance_B is destroyed is the destructor for class A also called?
>
> If so does the same thing happen for constructors?
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
> Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
> Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
> REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|