#include <iostream>
#include <string>
using namespace std;
class A{
      public:
         A(){
          cout<<"A : constructor"<<endl;
          }
         ~A(){
           cout<<"A : destructor"<<endl;      
         }
      };

class Counter: public A {
    protected:
     unsigned int count;
    public:
      Counter() : count(0)
      { cout<<"Counter: Constructor"<<endl; }
      Counter(int c) : count(c) 
      { }
      int get_count()
      { return count; }
      Counter operator ++ () {
        return Counter(++count);
      }
      ~Counter(){
        cout<<"Counter: destructor"<<endl;           
      }
};
class CountDn : public Counter {
  public:
    CountDn()  
    { cout<<"CountDn: Constructor"<<endl; }
    CountDn(int c) : Counter(c)
    { }
    Counter operator -- () { 
      return Counter(--count); 
    }
    ~CountDn(){
      cout<<"CountDn : Destructor"<<endl;           
    }
};
main() {
     CountDn *c1 = new CountDn;
     system("pause");
     delete c1;  
    //CountDn c1;
    //A a;
    /*
    cout << "\nc1=" << c1.get_count(); 
    ++c1; ++c1; ++c1; 
    cout << "\nc1=" << c1.get_count(); 
    --c1; --c1; 
    cout << "\nc1=" << c1.get_count()<<endl; 
    */system("pause");
}







