Static member Variable: –

Static member Variable: – When the member variable is prefixed with static keyword then the member variable is said to be static member variable. The few points about static member variable are –

(1) It is associated with class rather than object.

(2) Unlike non-static member variable, it is created only once separately outside the object.

(3) In C++, it is initialized from outside the class as –

Syntax: –

                Data_Type Class_Name::Variable_Name=Value;


                Int demo::i=10;

(4) All the objects of a class will share this variable. When any object among all makes changing to this variable then the latest value will be affected to all the objects.

(5) The purpose of it, when the programmer needs to have a common data to all the objects.


Comments are closed.

Create a website or blog at

Up ↑

%d bloggers like this: