A zero value is the type-dependent value assigned during a relevant initialization operation. In C++, a compiler-generated default constructor can initialize instance variables to their type’s zero value, but the constructor is not called in every variable-definition form. An uninitialized value may instead contain unpredictable data and produce undefined behavior. section 7.3
Use zero values carefully when maintaining object state:
- Initialize every instance variable when the class invariant requires a valid state. section 7.3
- Represent an absent exclusive resource with a clear, detectable zero or invalid value. section 8.6
- Use nullptr rather than NULL for pointer zero values in modern C++. section 8.6
- Do not choose zero when zero is a legitimate value; select another representation that preserves the invariant. section 8.6
The initialization form changes the result
Given `Person { int age; std::string name; };`, `Person p1;` can leave `age` indeterminate, while `Person p2 = Person();` value-initializes the object and supplies type-dependent zero values. A safer design requires constructor arguments or provides an explicit constructor such as `Person() : name("Joey"), age(21) {}` when those values satisfy the invariant. section 7.3




