Some knowledge points of variable initialization

"C++ Programming Language (Fourth Edition)" Chapter 2.2.2

1. Use the initialization list as much as possible: initialize variables in the form of {} instead of "=";

2. The initialization list will not narrow the type conversion (for example: int i = 7.2);

3. Except for the following situations, use auto as much as possible:

  • Variables are defined in a larger scope
  • Need to clarify the precision and range (such as double and float)

Guess you like

Origin blog.csdn.net/kenfan1647/article/details/113781703