C++ Language/Variables/Initialization

From Wikibooks, open books for an open world
Jump to navigation Jump to search

A constant variable (marked by the const keyword) must be initialized. If a static-lifetime variable is not manually initialized, then it will be automatically initialized to 0. If a local object variable is not manually initialized, then its default-constructor will construct it. If a local primitive variable is not manually initialized, then its value will be undefined until something gets assigned to it.

Additional information about initialization (includes interactive examples)