Class C++ Tutorial

#include  
using namespace std; 
 
class BaseClass { 
public: 
  BaseClass() { cout << "Constructing base portion\n"; } 
  ~BaseClass() { cout << "Destructing base portion\n"; } 
}; 
 
class DerivedClass: public BaseClass { 
public: 
  DerivedClass() { cout << "Constructing derived portion\n"; } 
  ~DerivedClass() { cout << "Destructing derived portion\n"; } 
}; 
 
int main() 

  DerivedClass ob; 
 
  // do nothing but construct and destruct ob 
 
  return 0; 
}
Constructing base portion
Constructing derived portion
Destructing derived portion
Destructing base portion