Take Charge and Initialize Your Own Data

C++ doesn't initialize automatic variables for you, and if you're unfamiliar with the right syntax or aggregate initialization, you can misuse important library functionsor you might be tempted to skip initialization altogether. Avoid creating unnecessary performance overhead, future maintenance problems, and potential bugs by learning how to correctly initialize data on your own.

Step 1: Initialization of Fundamental Datatypes
Initialization of fundamental types such as int, bool, and double is simple. Just place an assignment operator followed by a proper initializer in the declaration. For example:

Notice that each initializer is of the correct type. This isn't really necessary since, as a special case, C++ allows you to use 0 as a universal initializer for fundamental types, including pointers, pointers to functions and even pointers to members. Therefore, you may initialize temp like this: