Constructor of type int

后端 未结 5 781
醉酒成梦
醉酒成梦 2020-12-01 23:43

Considering the cost, are these cases the same?

// case 1
int a = 5;

// case 2
int a (5);

// case 3
int a;
a = 5
5条回答
  •  春和景丽
    2020-12-02 00:06

    First and second are exactly same as both are initialization. Third one is different, as this is assignment. These differences are as per the C++ Standard. However, the compiler can treat all three as same!

提交回复
热议问题