Mail Archives: djgpp/1998/06/01/13:01:38
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
- Raw text -