Tips: Static Keyword



Static is one of storage class in C++. It is the default storage class for global variables. 


Static variable can not extend from one file to another file (using 'extern' keyword) even if it is a global variable.

Static can also be defined within a function. If this is done the variable is initialised at run-time, but is not re-initialised when the function is called. Static variable inside the function retains its value during various calls.

Member variables declared as static inside the class is also called as class variable. If it is a static member of a class, it has to be initialized out side the class. But initialization should be in .cpp file.

If it is a static const member, then it should be initialized while declaring the member.