- //文件名:CHAPTER1-19.cpp
- #include <iostream.h>
- class Base
- {
- public:
- virtual ~Base() { cout<< "~Base" << endl ; }
- };
- class Derived : public Base
- {
- public:
- virtual ~Derived() { cout<< "~Derived" << endl ; }
- };
- void main(void)
- {
- Base * pB = new Derived; // upcast
- delete pB;
- }