Static members
Class members which are declared as static are known as Static members. Always Static variable shares same memory location.

Static int a;
Static void show();

Static Variables
The data members which are declared static are known as static variables.

#include <iostream> 
using namespace std;
class num
static int c;
void count()
cout&lt;&lt;"value of c is";
int num::c=10;
int main()
num obj1,obj2;

1. Here static data member variables must be initialised otherwise the linker will
generate an error.
2. The memory for static data members is allocated only once
3. Only one copy of static member variable is created for the whole class for any
number of objects. All the objects have common static data members.

Static Member Function
The member function which are declared static are known as static member function. Only static keyword before a member function makes a member function static. Static member function can only access static members of the corresponding class.

Private static function must be invoked using static public function

Share with : Share on Linkedin Share on Twitter Share on WhatsApp Share on Facebook