This is aggregated initialization and is valid C and valid C ++.
C ++ additionally allows you to omit all initializers (for example, zero), but for both languages objects without an initializer are initialized with initialization or initialized with zero:
// C++ code: struct A { int n; std::string s; double f; }; A a = {}; // This is the same as = {0, std::string(), 0.0}; with the // caveat that the default constructor is used instead of a temporary // then copy construction. // C does not have constructors, of course, and zero-initializes for // any unspecified initializer. (Zero-initialization and value- // initialization are identical in C++ for types with trivial ctors.)
source share