Thanks m37h0d and Elysia!
I made some changes in above code(just to check behavior).
changes are 1. base class is using default '=' operator.
2. derive class is using overloaded '=' operator.
Code:
class base
{
public:
int b;
base(int i ):b(i) {}
/*base& operator = (base& obj)
{
cout<<endl<<"In base = operator"<<endl;
return *this;
}*/
};
class derive : public base
{
public:
int d;
derive(int j, int k):d(j),base(k){}
derive& operator = (derive& obj)
{
base::operator = (obj);
cout<<endl<<"In derive = operator"<<endl;
d = obj.d;
return *this;
}
};
void main()
{
derive obj1(10,20), obj2(30,40);
obj1 = obj2;
}
Now if I dont add undelined code statement base class default = implementation is not invoked. I think while overloading derive class = one need to make sure he calls base:perator = (base&)
Thanks,
Ketan