#include <iostream>
using namespace std;
class myclass {
public:
myclass();
myclass(const myclass &o);
myclass f();
};
myclass:: myclass(){
cout<<"Constructing normally"<<endl;
};
myclass:: myclass(const myclass &o){
cout<<"Constructing copy"<<endl;
};
myclass myclass::f(){
myclass temp;
return temp;
};
int main(){
myclass obj;
obj = obj.f();
return 0;
}
I found this example in a book which shows that the output of the program should be:
Constructing normally
Constructing normally
Constructing copy
But when i compile it in my compiler it only shows the output written below
Constructing normally
Constructing normally
What is actually happening inside?