Possible Duplicate:
Shortcut for constructor
Are the following pieces of code the same in C++:
Piece1:
MyFunnyClass o = MyFunnyClass();
Piece2:
MyFunnyClass o;
I am aware that the following is not equivalent, but I am not sure about the two on the top:
MyFunnyClass o = MyFunnyClass () ;
MyFunnyClass o;
o = MyFunnyClass();
This does not define an object in any way at all. This is the Most Vexing Parse.
ois a function which takes nothing and returns aMyFunnyClass, which you have declared.The real syntax would be
This would default-construct an object.
Value-constructs an object and then copies or moves it into
o. Expect ellision here.