compiler generated destructor vs class implemented destructor

Discussion in 'C++' started by arun, Jun 12, 2006.

  1. arun

    arun Guest

    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
     
    arun, Jun 12, 2006
    #1
    1. Advertising

  2. arun

    Noah Roberts Guest

    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.
     
    Noah Roberts, Jun 12, 2006
    #2
    1. Advertising

  3. arun

    benben Guest

    [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
     
    benben, Jun 13, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. qazmlp
    Replies:
    1
    Views:
    590
    qazmlp
    Apr 10, 2005
  2. frs
    Replies:
    20
    Views:
    792
    Alf P. Steinbach
    Sep 21, 2005
  3. arun
    Replies:
    2
    Views:
    314
    n2xssvv g02gfr12930
    Jun 12, 2006
  4. arun
    Replies:
    0
    Views:
    320
  5. Replies:
    22
    Views:
    847
    Frederick
    Jul 3, 2006
Loading...

Share This Page