destructor (any need)

This is a discussion on destructor (any need) within the C++ Programming forums, part of the General Programming Boards category; when creating objects of a class is there any need to include a user defined destructor to destroy them or ...

  1. #1
    Unregistered
    Guest

    destructor (any need)

    when creating objects of a class is there any need to include a user defined destructor to destroy them or am I better of with the default one ie. is there any need for a desructor when it just deals with objects.

    thanks.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Well if you have allocated memory on the freestore with new....then where better to call delete on the pointer before you lose scope..

    If you dont you will have memory leaks...

    If it is a simple class where all variables are on the stack then you could get away with it

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21