A
Aneel
Does assignment operator also creates object, as created by copy
constructor, in classes. e.g.
class check {
int x;
public:
check(int a=0):x(a){cout<<"\nconstructor\n";}
check operator = (const check &rhs){cout<<"\nassignment operator
\n";}
~check(){cout<<"\ndestructor\n";}
};
int main() {
check ob1(3), ob2(4);
ob1=ob2; // does this create a temporary copy of ob1 or ob2;
return 0;
}
return 0;
}
constructor, in classes. e.g.
class check {
int x;
public:
check(int a=0):x(a){cout<<"\nconstructor\n";}
check operator = (const check &rhs){cout<<"\nassignment operator
\n";}
~check(){cout<<"\ndestructor\n";}
};
int main() {
check ob1(3), ob2(4);
ob1=ob2; // does this create a temporary copy of ob1 or ob2;
return 0;
}
return 0;
}