Thread: destructor (any need)

  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,793
    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