I'm having some doubts about this line:
Foo obj = Foo();
From what I know, here should be a constructor call for Foo() and then the copy constructor is called in order to initialize obj, but when I run this, the output shows that only the constructor is being called once. I know that the compiler does some optimizations on it's behalf, but I'm not sure whether this is one of them or maybe I'm just being wrong. The natural (without compiler optimization) call of constructors would be Constructor -> Copy Constructor and then Destructor(for temporary Foo() object)?
I'm not asking for practical use, but rather theoretical. I'm having an exam this days and I have to know the theoretical call of constructors, without optimizations.