C++ - initializing variables in header vs with constructor

前端 未结 7 1107
盖世英雄少女心
盖世英雄少女心 2021-01-31 02:00

Regarding the following, are there any reasons to do one over the other or are they roughly equivalent?

class Something
{
    int m_a = 0;
};

v

7条回答
  •  忘掉有多难
    2021-01-31 02:29

    The first form is new to C++11 and so at this point isn't terribly well supported, especially if you need to support a variety of older compilers.

    Otherwise they should be roughly equivalent when a C++11 compiler is available.

提交回复
热议问题