#include <iostream>
using namespace std;
class SoSimple
{
private:
int num;
public:
SoSimple(int n) : num(n)
{
cout << "New Object : " << this << endl;
}
SoSimple(const SoSimple& copy) :num(copy.num)
{
cout << "New Copy obj: " << this << endl;
}
~SoSimple()
{
cout << "Destory obj: " << this << endl;
}
};
SoSimple SimpleFuncObj(SoSimple ob)
{
cout << "Parm ADR: " << &ob << endl;
return ob;
}
int main(void)
{
SoSimple obj(7);
SimpleFuncObj(obj);
cout << endl;
SoSimple tempRef = SimpleFuncObj(obj);
cout << "Return Obj " << &tempRef << endl;
return 0;
}
SoSimple tempRef = SimpleFuncObj(obj);
여기서 tempRef로 SimpleFuncObj(obj)이 복사생성 될줄 알았는데 안그러더라구요.
이리저리 검색해본결과 컴파일러가 효율을 위해 따로 tempRef를 생성하지않는다라고
나와있던데 원래 그런건가요 ?