Welcome, Guest. Please login or register.

Author Topic: question about C++ constructors  (Read 23029 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline jack

  • Newbie
  • *
  • Join Date: Feb 2002
  • Posts: 41
    • Show all replies
Re: question about C++ constructors
« on: January 24, 2003, 09:31:38 AM »
If u really have to allocate stuff in constructor, the best way is to build your own class which acts like the one you want to allocate. Make it(the new class) deallocate the stuff allocated by itself  in destructor. You can even add copy constructors, = operator etc (don't forget to use deep copy when implementing "=") . You will end with your own memory manager, little preformance loss, but it will prevent memory leaks. If you want example - let me know.


Jack.