In this specific case, is there a difference between using a member initializer list and assigning values in a constructor?

后端 未结 12 1074
北恋
北恋 2020-11-22 08:16

Internally and about the generated code, is there a really difference between :

MyClass::MyClass(): _capacity(15), _data(NULL), _len(0)
{
}

12条回答
  •  情深已故
    2020-11-22 08:39

    If you write an initializer list, you do all in one step; if you don't write an initilizer list, you'll do 2 steps: one for declaration and one for asign the value.

提交回复
热议问题