What are primitive types default-initialized to in C++?

前端 未结 6 1973
无人及你
无人及你 2020-11-27 14:05

When I use an initialization list:

struct Struct {
    Struct() : memberVariable() {}
    int memberVariable;
};

the primitive type (

6条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 14:37

    0

    If you call () on a primitive, the effect is the same as assigning the default value it would have been given if it had been static.

提交回复
热议问题