Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Default initialization in C++ will leave primitive types with an unspecified value and objects with a default constructor called, while value initialization will set primitive types to 0 and objects to their default value.

Default initialization is called when an object is declared without an initializer, while value initialization is called when an object is declared with an empty initializer.

The best method to reliably initialize a member with a template type is to use value initialization. This ensures that objects are initialized to their default value, regardless of the type of the object.