#include <cstdlib>
#include <iostream>
using namespace std;
class man{
int i ;
public:
man(){
i=23;
cout << "\n defaul constructir called\t"<< i<<"\n";
}
man (const man & X) {
i = 24;
cout << "\n COPY constructir called\t"<< i<<"\n";
}
man & operator = (man x) {
i = 25;
cout << "\n = operator called\t"<< i<<"\n";
return *this;
}
};
int main(int argc, char *argv[])
{
man x;
cout <<"\n ----------\n";
man y = x;
cout <<"\n ----------\n";
x=y;
return 0;
}
가 출력
defaul constructir called 23
----------
COPY constructir called 24
----------
COPY constructir called 24
= operator called 25
이 출력은 X = Y의 세 번째 통화 이상한에 도시 이상한 행동을 표시하는 프로그램을 가지고;
왜 새 개체를 만들지 않았지만 이전 개체로 작업 할 때 불리는 복사본 구성 자의 추가 인쇄가 있습니다.
는 중간에 임시 개체의 becuase 그래 내가 여기에 그들을 막을 수 있다면 ....
감사합니다. @OilCharlesworth. – MAG