While explicitly instantiating vector, what is the someType default constructor used for?

后端 未结 3 684
滥情空心
滥情空心 2021-02-10 08:09

It\'s an exercise from C++ Primer 5th Edition:

Exercise 16.26: Assuming NoDefault is a class that does not have a default constructor, can we e

3条回答
  •  盖世英雄少女心
    2021-02-10 08:48

    While explicitly instantiating std::vector, what is the someType default constructor used for?

    It's used to construct the elements of the array when resizing the std::vector. For example:

    std::vector vector(10);
    

    will default construct 10 elements of type T.

提交回复
热议问题