qfedu-cpp-level/day4/homework/h3.cpp

35 lines
448 B
C++

// 运行以下程序,写出其输出的结果?
#include <iostream>
using namespace std;
class Test
{
public:
Test(int i = 0)
{
cout << i;
}
Test(const Test &x)
{
cout << 2;
}
Test &operator=(const Test &x)
{
cout << 3;
return *this;
}
~Test()
{
cout << 4;
}
};
int main()
{
Test obj1(1), obj2(2);
Test obj3 = obj1;
return 0;
}
/* 122444 */