I've read that those two syntaxes aren't the same when instantiating an object:
ClassName c1(p);
and
ClassName c1 = ClassName(p);
(or without parameters due to constructor)
I've read the second syntax creates two objects one to be temporary with given parameters then copy constructor gets called. But when I create an object the second way, the cout
in the constructor and destructor prints one time each. That leads me to think if I am misinformed and these two ways are completely the same or the compiler automatically optimizes it and that causes it?
If it's because optimization is there a way to disable the optimization to see the difference between them?