>

To all those who commented on this question I just want to say Thank You
for all your help, pointers, insights, and knowledge. My knowledge of C++
constructors/destructors has vastly improved thanks to all the help and I
have successfully solved the problem which I was working on. Thanks...

/John <[EMAIL PROTECTED]>


> Lets say I have a class "foo"and within a constructor for this class I
> wish to use "new" to allocate memory space. For example:
>
> class foo
> {
>    private:
>       char *c;
>
>    public:
>       foo()                                          // constructor
>        { c = new char [LEN + 1]; }
>
> };
>
> Of course there would be other member functions.  Now lets say I write
> a program in which I create and use objects of class foo. When I am
> finished using those objects I want to deallocate the memory which was
> allocated when the object was constructed. To accomplish this can I
> just simply write a destructor which, in it's simplest form might look
> like this:
>
>    ~foo()
>      { delete c; }
>
> Would this work? and, if so, how would I call this destructor when the
> object is no longer needed, or would this be done automatically at
> some point??
>
> Any help would be appreciated. Pardon my ignorance of this topic but,
> I am in the process of trying to debug a small program which seems to
> be leaking memory from somewhere and the program utilizes a
> significant amount of C++ code.(I am curently in the learning stages
> of C++).
>
> Thanks,
>
> /John <[EMAIL PROTECTED]>
>
> --
> email: [EMAIL PROTECTED]
> Local mailserver  , remote

--
email: [EMAIL PROTECTED]
Local mailserver  , remote


Reply via email to