I am new to C ++. Please consider the following code:
class foo { int f; public: foo(int f1=0) : f(f1) { cout<<"In conversion ctor\n"; } foo(const foo & rhs) : f(rhs.f) { cout<<" In copy ctor\n"; } foo& operator=(const foo & that) { f=that.f; cout<<"In = optor\n"; return *this; } }; foo rbv() { foo obj(9); return obj;
Are the following steps performed correctly when creating a 'ret'
(1) a temporary (say, obj_temp) is created using copy ctor from obj, the stack of the object "obj" is destroyed,
(2) ret - a copy built from obj_temp, obj_temp destroyed later;
which implies the presence of three objects: obj ',' obj_temp 'and' ret 'and two instances of ctors.
Burt source share