65,210
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <iostream>
class CTest
{
public:
CTest()
: mInt(0)
{
printf("Default Constructor.\n");
}
CTest(const CTest& copyCons)
{
printf("Copy Constructor.\n");
this->mInt = copyCons.getIntValue();
}
~CTest() {}
void printIntValue()
{
printf("%d\n", mInt);
}
int getIntValue() const
{
return mInt;
}
void operator = (const CTest& copyCons)
{
printf("Operator =\n");
this->mInt = copyCons.getIntValue();
}
private:
int mInt;
};
int main()
{
CTest a;
CTest b(a);
CTest c = a;
c = b;
system("pause");
return 0;
}