The return X() in the f5 function creates a temporary object of class X with the default constructor (ii=0) and copies it to the variable where you assigned the result. E.g.:
X myVar;
myVar = f5();
myVar.i will be equal to 0. (I don't remember if the compiler generates the default copy constructor)
Best regards,
Mauro H. Leggieri **broken link removed**
The return X() in the f5 function creates a temporary object of class X with the default constructor (ii=0) and copies it to the variable where you assigned the result. E.g.:
X myVar;
myVar = f5();
myVar.i will be equal to 0. (I don't remember if the compiler generates the default copy constructor)
Best regards,
Mauro H. Leggieri
h**p://www.mauroleggieri.com.ar
I dont completly understand your question. f5() func simply return X object with default construction and the func Modify() was never called. I think that's all.
The function f5 creates temporary object of class X by calling the constructor you have declared X::X(int ii) with ii value with 0 and returns the same to the caller. Remember you have defined a single argument constructor with default value. If you dont supply a value while calling a constructor, it will call this single argument constructor with default value you specified ie 0 in this case.
If there is no copy-constructor, constructor, destructor then compiler will create.