Why isnt the copy constructor of member class called?
Posted
by sandeep
on Stack Overflow
See other posts from Stack Overflow
or by sandeep
Published on 2010-03-31T06:06:46Z
Indexed on
2010/03/31
6:13 UTC
Read the original article
Hit count: 455
c++
class member
{
public:
member()
{
cout<<"Calling member constr"<<'\n';
}
member(const member&)
{
cout<<"Calling member copy constr"<<'\n';
}
};
class fred
{
public:
fred()
{
cout<<"calling fred constr"<<'\n';
}
fred(const fred &)
{
cout<<"Calling fred copy constr"<<'\n';
}
protected:
member member_;
};
int main()
{
fred a;
fred b=a;
}
Output:
Calling member constr
calling fred constr
**Calling member constr**
Calling fred copy constr
© Stack Overflow or respective owner