Does in class member initialization takes place at compile time or run-time?

前端 未结 5 1111
醉话见心
醉话见心 2021-02-02 09:42

In C++11 a new feature was introduced where the programmer can initialize class member variables inside class\'s definition, see code below:

struct foo
{ 
  int         


        
5条回答
  •  滥情空心
    2021-02-02 10:10

    It's just syntactic sugar. Also consider that an instance usually means memory which has to be initialized with the correct values. Just because these values are provided with a different syntax does not change the fact that the memory needs to be initialized - which happens at run-time.

提交回复
热议问题