From: sl AT psycode DOT com DOT NOSPAM (Gili) Newsgroups: comp.os.msdos.djgpp Subject: Classes, Cloning and memory loss Date: 1 Jun 1998 12:07:31 GMT Organization: All USENET -- http://www.Supernews.com Lines: 24 Message-ID: Reply-To: sl AT psycode DOT com DOT NOSPAM NNTP-Posting-Host: 205.205.70.64 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Hello, I have the following class: class SLList { public: SLList *clone(); operator=(); private: int *value; } clone() creates another instance of the class, containing the same value for 'value', but not the same pointer (it allocates new memory.) Operator=() deletes the old instance and copies the memory location of the new instance (shares the memory.) My question is... If I say 'temp=someSLList.clone()'... someSLList.clone() never gets delete()d, temp does.. But since temp and someSLList shared the same value, is delete()ing temp enough? Will someSLList be left floating somewhere in memory if I only delete() its variables from another instance? Thank you, Gili