home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 15912 < prev    next >
Encoding:
Text File  |  1992-11-08  |  1.2 KB  |  38 lines

  1. Newsgroups: comp.lang.c++
  2. From: nikki@trmphrst.demon.co.uk (Nikki Locke)
  3. Path: sparky!uunet!pipex!demon!trmphrst.demon.co.uk!nikki
  4. Subject: Re: deleting objects and destructors in derived classes
  5. Reply-To: nikki@trmphrst.demon.co.uk
  6. Distribution: world
  7. X-Mailer: cppnews $Revision: 1.20 $
  8. Organization: Trumphurst Ltd.
  9. Lines: 24
  10. Date: Thu, 5 Nov 1992 13:19:01 +0000
  11. Message-ID: <720994741snx@trmphrst.demon.co.uk>
  12. Sender: usenet@gate.demon.co.uk
  13.  
  14. In article <Bx7598.AzG@gabriel.keele.ac.uk> csd05@seq1.keele.ac.uk writes:
  15. > I have a problem with deleting objects of derived class via a pointer
  16. > of base class. It seems to me that doing so the things added in the derived
  17. > class are not cleaned up. Here is the example:
  18. > #include <stream.h>
  19. > class Base {
  20. > protected:
  21. >     char* _name;
  22. > public:
  23. >     char* ClassName() { return "Base:"; }
  24. >     Base(char* name) { 
  25. >         cout << "Constructor " << ClassName() << name << "\n"; 
  26. >         _name = name;
  27. >     }
  28.  
  29. Insert the word "virtual" just here
  30.  
  31. >     ~Base() { cout << "Destructor  " << ClassName() << _name << "\n"; }
  32. > };
  33. -- 
  34. Nikki Locke,Trumphurst Ltd.(PC and Unix consultancy) nikki@trmphrst.demon.co.uk
  35. trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
  36.