这两个程序的区别在哪呢 硬是没有看出来啊 大家帮忙看看
class A{ public:
A()
{
cout<<"A"<<endl;
}
~A()
{
cout<<"~A"<<endl;
}
};
class B
{
public:
B(A &a)
{
cout<<"B"<<endl;
_a=a;
}
~B()
{
cout<<"~B"<<endl;
}
private:
A _a;
};
int main()
{
A a;
B b(a);
return 0;
}
class A
{ public:
A()
{
cout<<"A"<<endl;
}
~A()
{
cout<<"~A"<<endl;
}
};
class B
{
public:
B(A &a):_a(a)
{
cout<<"B"<<endl;
}
~B()
{
cout<<"~B"<<endl;
}
private:
A _a;
};
int main()
{
A a;
B b(a);
return 0;
}
以上两段程序的输出结果怎么会不同呢