#include<iostream>
    using namespace std;
    class base
    {
    int i;
    public:
    base()
    {
    i=10;
    cout<<"Base Constructor\n";
    }
    base(base &a)
    {
    cout<<"base Copy Constructor\n";
    a.i=i;
    }
    ~base()
    {
    cout<<"base Destructor\n";
    cout<<i<<endl;
    }
    };
    class derived:public base
    {
    int j;
    public:
    derived()
    {
    j=20;
    cout<<"derived Constructor\n";
    }
    derived(derived &a)
    {
    cout<<"derived Copy Constructor\n";
    a.j=j;
    cout<<j<<endl;
    }
    ~derived()
    {
    cout<<"derived Destructor\n";
    }
    };
    main()
    {
    base obj;
    base obj1=obj;
    derived ob;
    derived ob1=ob;
    }
i am a beginner in cpp i was trying to understand single inheritance how it behaves how its const,dest behaves but got a problem in the derived class derived member giving garbage value.. can somebody explain me.
 
     
     
    