0
Creating object in c++
if i have a class like this class Example{ public: int y; Example(int x){y = x;} }; and in main function i try to create two objects with difference ways Example a = Example(3); Example b(Example(3)); I know that i can use "Example a(3)" to create object,but what is the difference between object a and b?are they the same?if not,whats the differencd
2 Respostas
+ 1
They are the same, optimization ( copy elision ) makes sure only 1 object is constructed.
Only difference is that they use uglier syntax, but that's just my opinion.
0
oh..ok
tq for the answer