Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #15357

Re: memory allocation/deaalocation in calss

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: memory allocation/deaalocation in calss
Date 2012-04-14 09:36 +1200
Message-ID <9urkj6FjbhU1@mid.individual.net> (permalink)
References <28714271.3.1334350972034.JavaMail.geo-discussion-forums@pbcuv5>

Show all headers | View raw


On 04/14/12 09:02 AM, asit wrote:
> I have a LinkedList class which has a function which allocates memory.
>
> I need to add user defined copy constructor and assignment operator.
>
> In case of assignment operator, I need to free the existing memory allocated(which is done by my destructor). Should I call destructor inside that assignment operator body ?

A cleaner solution is to add a member function to manage the free and 
call that from both places.

-- 
Ian Collins

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

memory allocation/deaalocation in calss asit <lipun4u@gmail.com> - 2012-04-13 14:02 -0700
  Re: memory allocation/deaalocation in calss "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-04-13 23:35 +0200
  Re: memory allocation/deaalocation in calss Ian Collins <ian-news@hotmail.com> - 2012-04-14 09:36 +1200
  Re: memory allocation/deaalocation in calss Kevin McCarty <kmccarty@gmail.com> - 2012-04-13 14:35 -0700
    Re: memory allocation/deaalocation in calss Juha Nieminen <nospam@thanks.invalid> - 2012-04-14 05:27 +0000
      Re: memory allocation/deaalocation in calss Christopher Creutzig <christopher@creutzig.de> - 2012-04-26 19:46 +0200
  Re: memory allocation/deaalocation in calss asit <lipun4u@gmail.com> - 2012-04-13 15:17 -0700
    Re: memory allocation/deaalocation in calss Ian Collins <ian-news@hotmail.com> - 2012-04-14 11:29 +1200
  Re: memory allocation/deaalocation in calss asit <lipun4u@gmail.com> - 2012-04-13 15:31 -0700

csiph-web