Calling constructor with braces

后端 未结 2 1286
无人及你
无人及你 2020-12-03 15:23

Simple question about C++11 syntaxis. There is a sample code (reduced one from source)

struct Wanderer
{
  explicit Wanderer(std::vector

        
2条回答
  •  有刺的猬
    2020-12-03 15:37

    It is just C++11 syntax. You can initialize objects calling their constructor with curly braces. You just have to bear in mind that if the type has an initializer_list constructor, that one takes precedence.

提交回复
热议问题