Skip to main content
1 of 9
Sarfaraz Nawaz
  • 363.4k
  • 121
  • 682
  • 867

Dynamic initialization is that in which initialization value isn't known at compile-time. Its computed at runtime to initialize the variable.

int f(); //some function int a = 10 ; //static initialization int b = f(); //dynamic initialization 

That is, static initialization involves constant-expression, while dynamic initialization involves non-constant expression.

Objects with static storage duration (3.7.1) shall be zero-initialized (8.5) before any other initialization takes place. Zero-initialization and initialization with a constant expression are collectively called static initialization; all other initialization is dynamic initialization.

Sarfaraz Nawaz
  • 363.4k
  • 121
  • 682
  • 867