+ 1

c++ create object

may i know what the difference Example a; Example b = Example();

5th Apr 2020, 4:25 PM
durian
durian - avatar
3 Antworten
0
Example a; calls default constructor. Example b = Example (); this is a value initialization assignment syntax that will help with Most Vexing parse. It will still call default constructor and it will also help with ambiguity i.e if you were to try to do this Example b(); , so by doing Example b = Example (), you avoid ambiguity. Hope it helps.
6th Apr 2020, 1:01 PM
Jay W
0
tq..got it
6th Apr 2020, 1:08 PM
durian
durian - avatar
0
You're welcome
6th Apr 2020, 1:09 PM
Jay W