Base and Derived class copy constructor help.
I have
Code:
class Base {
int a;
public:
Base();
Base(int);
Base(const Base& b); //copy constructor
};
Base::Base(const Base& b){
a=b.a;}
class Derived public: Base{
int x;
public:
Derived();
Derived(int);
Derived(const Derived& d); //copy constructor
};
Derived::Derived(const Derived& d) :Base(d){ //<--MY QUESTION HERE.
x=d.x;
}
how the Base copy constructor will be executed?
d is a reference to Derived class. It is not a reference to a Base class.
Any help will be appreciated.