home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C15 / Pvdest.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  557 b   |  29 lines

  1. //: C15:Pvdest.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. // Pure virtual destructors
  7. // require a function body.
  8. #include <iostream>
  9. using namespace std;
  10.  
  11. class Base {
  12. public:
  13.   virtual ~Base() {
  14.     cout << "~Base()" << endl;
  15.   }
  16. };
  17.  
  18. class Derived : public Base {
  19. public:
  20.   ~Derived() {
  21.     cout << "~Derived()" << endl;
  22.   }
  23. };
  24.  
  25. int main() {
  26.   Base* bp = new Derived; // Upcast
  27.   delete bp; // Virtual destructor call
  28. } ///:~
  29.