C ++ Primer: the difference between variable declarations and definitions


1. similarities

  Declarations and definitions specifies the type and name of the variable.

2. Different points

  1. Defined application storage space, it may be assigned an initial value for the variable, but the statement does not;
  2. Variables can be defined only once, but can be declared multiple times.

3. Examples

extern int i1; // 声明i1
int i2; // 声明并定义i2
extern int i3 =1; // 定义i3
Published 77 original articles · won praise 25 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_34801642/article/details/103884921
Recommended