Initialization difference with or without Curly braces in C++11

后端 未结 3 1325
野性不改
野性不改 2020-11-29 23:22

We can initialize the variable in two ways in C++11

One:

int abc = 7;

Two:

int ab         


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-29 23:35

    The first is the copy initialization, while the second is list initialization.

    But, usually copy initialization is less used. Because, if you're doing it by passing objects of user defined types, it just causes bitcopy & hence may not produce intended results if the user defined class uses pointers.

提交回复
热议问题