From: Hilaire Fernandes Newsgroups: comp.os.msdos.djgpp Subject: Re: newbie questions about C++ Date: Sat, 29 Mar 1997 13:27:03 +0800 Organization: DCI HiNet Message-ID: <333CA827.1545@ms11.hinet.net> References: <333BE16F DOT 7C80 AT ms11 DOT hinet DOT net> <333C0AE3 DOT 5530AE41 AT alcyone DOT com> NNTP-Posting-Host: 168.95.102.1 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 27 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp > > Q1) delete(s); EQUAL TO delete(f) ?? > > If they point to the same object (which they do here), yes. Even If I do : void *p; p=(void *)s; delete(p) EQUAL TO delete(s) ?? So delete doesn't need to know the type of pointer to free memory ! Great! Another question : Do delete call the destructor when is argument is a pointer to a class ? > > Q3) I could use a virtual function calling the good destructor for each > > kind of class but I'm not sure the destructor free the memory taken by the new function ?? > Huh? Just make your destructor virtual and do the right thing there. (You > can make destructors virtual, but not constructors.*) I'm not sure but it seem when you call a destructor you need to makeout the class type like this ' s->son::~son() ' . So If I don't know the class type (here son) it's not possible ! Don't you ? Thank for your help Hilaire