Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: All
Jan 18, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Understanding Zero Initialization

To zero-initialize an object of type T means that the memory storage occupied by the object is set to binary zeros. More precisely, if T is a built-in data type, an enumeration type, or a pointer type, the storage is set to the value of 0 converted to T. For aggregates and class objects, zero-initialization means one of the following:

  • For a class type, the storage for each data member and each base-class subobject is zero-initialized.
  • For a union type, the storage for its first data member is zero-initialized.
  • For an array type, the storage for each element is zero-initialized.

However, if T is a reference type, no initialization is performed because there are no null references in C++.

Danny Kalev
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date