在下面的示例中,为什么other.age
输出 88 而不是 0?
#include <atlstr.h>//CString for non-MFC
class A
{
public:
A() : name("Nobody"), age(0) {}
~A(){};
A( CString name, unsigned age ) : name( name ), age( age ) {}
A& operator=( const A& ref )
{
name = ref.name;
age = 0;
}
CString name;
unsigned int age;
};
int _tmain( int argc, _TCHAR* argv[] )
{
A person( CString("Michael"), 88 );
A other = person;
std::cout << other.name << std::endl << other.age;
}