source file name: staticdata.cpp

 #include<conio.h>

#include<iostream.h>

class Counter

{

static int cnt;

int no;

public:

void getno(int m)

{

no=m;

cnt++;

}

void getcount()

{

cout<<" count: "<<cnt<< " no: "<<no <<endl;

}

};

int Counter::cnt;

void main()

{

clrscr();

cout<<"Program on static data type"<<endl;

Counter ob1,ob2,ob3;

cout<<"before reading numbers:"<<endl;

ob1.getcount();

ob2.getcount();

ob3.getcount();


ob1.getno(10);

ob2.getno(20);

ob3.getno(30);

cout<<"after reading numbers:"<<endl;


ob1.getcount();

ob2.getcount();

ob3.getcount();


getch();

}

output: