Can a member struct be zero-init from the constructor initializer list without calling memset?

前端 未结 3 733
时光说笑
时光说笑 2020-12-29 05:53

Let\'s say I have the following structure declaration (simple struct with no constructor).

struct Foo
{
    int x;
    int y;
    int z;
    char szData[DATA         


        
3条回答
  •  暖寄归人
    2020-12-29 06:33

    i find it hard to read the standard, but I found it I think:

    To value-initialize an object of type T means:
    if T is a non-union class type without a user-declared constructor, then every non-static data member and base- class component of T is value-initialized Value-initialization for such a class object may be implemented by zero-initializing the object and then calling the default constructor.

    Section 8.5

提交回复
热议问题