Where can we use list initialization?

后端 未结 3 545
忘了有多久
忘了有多久 2020-12-08 23:12

This question already covers what PODs and aggregates are, and provides some examples on aggregate initialization.

The question here is where can you use li

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 23:44

    List-initialization can be used to initialize dynamically-allocated arrays (C++11):

    int * a = new int[3] {4, 3, 2};
    

    A very nifty feature not possible in C++03.

提交回复
热议问题