Newsgroups: comp.lang.c++
Path: utzoo!utgpu!cunews!bnrgate!bwdls61!bwdls35!gwaters
From: gwaters@bwdls35.bnr.ca (Glenn Waters)
Message-ID: <1991Mar12.201900.19743@bwdls61.bnr.ca>
Sender: usenet@bwdls61.bnr.ca (Use Net)
Reply-To: gwaters@bwdls35.bnr.ca (Glenn Waters)
Organization: Bell-Northern Research
Date: Tue, 12 Mar 1991 20:19:00 GMT

The following program does not do what I would hope (expect). The third line of
main does a "delete bp". This seems to only delete String _b in the base class
and *not* String _d in the derived class. Is delete not a "virtual" delete
in that it will delete _d in the derived class? 

String is a simple string class. It suffices to say that String
has a constructor and destructor.
--------
#include <C++/string.hxx>

class base {
        String _b;
public:
        base() : _b("base initial value") {};
        ~base() {};
};

class derived : public base {
        String _d;
public:
        derived() : _d("derived initializer") {};
        ~derived() {};
};

main()
{
        derived* dp = new derived;
        base* bp = d;
        delete bp;
}

-- 
Glenn Waters, Network Management Systems      gwaters@bnr.ca
Bell-Northern Research, Ltd.                  ...!uunet!bwdls35!gwaters
P.O. Box 3511, Station C                      (613)763-3933 (Voice)
Ottawa Ontario Canada K1Y 4H7                 (613)763-3283 (FAX)
#include <standard_disclaimer.h>
