What is the default value for C++ class members

后端 未结 2 1126
执念已碎
执念已碎 2020-11-27 15:30

What is the default values for members of a struct and members of a class in c++, and how do these rules differ (e.g. between classes/structs/primitives/etc) ? Are there cir

2条回答
  •  醉梦人生
    2020-11-27 16:04

    Yeah, there is one. If you initialize an object with the default constructor and use parentheses then the POD members will be zero initialized:

    someClass * p = new someClass();
    

提交回复
热议问题