Differences between static, dynamic, volatile and constant variables
Anoniem
static : memory storage : data segment lifetime : it reserve its old value for each execution of its scope (if you call the function containing it many times , it will not be initialized each time of call , it will save the previous call's value) - destroyed at the end of the program (not at the end of its scope (i.e its function that the variable is declared inside)) dynamic : memory storage : heap (stored manually using malloc() ) lifetime : destroyed manually using delete() volatile : keyword to prevent compiler to optimize this variable and make it constant (because it appears to the compiler that it is not changing or I just read from it). constant : keyword to tell compiler that this variable won't change in the program at all ( prevent any statement wants to change in this variable). ex: const float pi = 3.14;