delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/28/18:44:24

From: Hilaire Fernandes <fernand AT ms11 DOT hinet DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: newbie questions about C++
Date: Fri, 28 Mar 1997 23:19:14 +0800
Organization: DCI HiNet
Lines: 35
Message-ID: <333BE16F.7C80@ms11.hinet.net>
NNTP-Posting-Host: 168.95.111.62
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hello All,

Excuse me if this is not the right newsgroup for these questions but I
am only subscribed to this one related to C.

My questions are about C++ programming and are linked with DJGPP only
because I use it.

Well let start my questions with an example :

father *f;		// father is a class
soon *s;		// soon is a type herited from father

s=new soon();
f=(father *)s;

So is : 

Q1) delete(s);   EQUAL TO   delete(f)  ??

Or should I use instead :

Q2) free(s);     EQUAL TO   free(f)	   ??

I have this problem because I have a chained list of differents kinds of
objects all herited of a father class but in the list all cast to the
type father. So I don't know any more their original type.

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 ?? 	 	

Thank you

Hilaire

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019