Correct way to initialize vector member variable

前端 未结 4 575
忘了有多久
忘了有多久 2021-01-30 02:16
// Method One
class ClassName
{
public:
    ClassName() : m_vecInts() {}

private:
    std::vector m_vecInts;
}

// Method Two
class ClassName
{
public:
    C         


        
4条回答
  •  暖寄归人
    2021-01-30 02:45

    You do not have to initialise it explcitly, it will be created when you create an instance of your class.

提交回复
热议问题