Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > compiler generated destructor vs class implemented destructor

Reply
Thread Tools

compiler generated destructor vs class implemented destructor

 
 
arun
Guest
Posts: n/a
 
      06-12-2006
Hello Group,

The compiler generated destructor will invoke destructor of each member

of the containing
class let us say 'class A'. However, if I write my own destructor for
class A like;


class Object1 {
// code here



};


class Object2{
// code here


};


class Object3 {
// code here


};


class A{
public:
Object1 o1;
Object2 o2;
Object3 o3;


};


The question is if I have a destructor and implement it as

~A() {}


Will the objects o1, o2, o3's destructor be still invoked, when class A

goes out of scope.


Thanks


nagrik

 
Reply With Quote
 
 
 
 
Noah Roberts
Guest
Posts: n/a
 
      06-12-2006

arun wrote:

> Will the objects o1, o2, o3's destructor be still invoked, when class A
>
> goes out of scope.


Please read the replies to your questions before posting them again.
Now I feel I just totally wasted my time answering this the first time.

 
Reply With Quote
 
 
 
 
benben
Guest
Posts: n/a
 
      06-13-2006
[snip]
>
> The question is if I have a destructor and implement it as
>
> ~A() {}
>
>
> Will the objects o1, o2, o3's destructor be still invoked, when class A
>
> goes out of scope.


Yes.

>
>
> Thanks
>
>
> nagrik
>


Regards
Ben
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Default functions implemented by compiler sujilc@gmail.com C++ 22 07-03-2006 05:27 PM
difference between compiler generated destructor and class implemented arun C++ 2 06-12-2006 09:39 PM
difference between compiler generated destructor and class implemented arun C++ 0 06-12-2006 05:34 PM
Explicit destructor calls from inside base class destructor frs C++ 20 09-21-2005 09:22 AM
Format of compiler generated derived destructor when base has 'virtual ~base() throw():" qazmlp C++ 1 04-10-2005 03:09 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57