Can I initialize an STL vector with 10 of the same integer in an initializer list?

后端 未结 6 1710
遇见更好的自我
遇见更好的自我 2021-01-31 07:54

Can I initialize an STL vector with 10 of the same integer in an initializer list? My attempts so far have failed me.

6条回答
  •  醉梦人生
    2021-01-31 08:12

    I think you mean this:

    struct test {
       std::vector v;
       test(int value) : v( 100, value ) {}
    };
    

提交回复
热议问题