home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- From: nikki@trmphrst.demon.co.uk (Nikki Locke)
- Path: sparky!uunet!pipex!demon!trmphrst.demon.co.uk!nikki
- Subject: Re: deleting objects and destructors in derived classes
- Reply-To: nikki@trmphrst.demon.co.uk
- Distribution: world
- X-Mailer: cppnews $Revision: 1.20 $
- Organization: Trumphurst Ltd.
- Lines: 24
- Date: Thu, 5 Nov 1992 13:19:01 +0000
- Message-ID: <720994741snx@trmphrst.demon.co.uk>
- Sender: usenet@gate.demon.co.uk
-
- In article <Bx7598.AzG@gabriel.keele.ac.uk> csd05@seq1.keele.ac.uk writes:
- > I have a problem with deleting objects of derived class via a pointer
- > of base class. It seems to me that doing so the things added in the derived
- > class are not cleaned up. Here is the example:
- >
- > #include <stream.h>
- >
- > class Base {
- > protected:
- > char* _name;
- > public:
- > char* ClassName() { return "Base:"; }
- > Base(char* name) {
- > cout << "Constructor " << ClassName() << name << "\n";
- > _name = name;
- > }
-
- Insert the word "virtual" just here
-
- > ~Base() { cout << "Destructor " << ClassName() << _name << "\n"; }
- > };
- --
- Nikki Locke,Trumphurst Ltd.(PC and Unix consultancy) nikki@trmphrst.demon.co.uk
- trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
-