/*PROGRAM TO SHOW COUNT HOW MANY INSTANCES OF CLASS OBJECT ARE CREATED USING CONCEPT OF STATIC MEMBER FUNCTIONS*/
#include<conio.h>
#include<iostream.h>
class stat_fun
{
static int count; //STATIC DATA DECLARATION
public:
stat_fun();
static void output(); //STATIC FUNCTION DECLARATION
};
stat_fun::stat_fun()
{
count++;
}
void stat_fun::output() //STATIC FUNCTION DEFINTION
{
cout<<“Counter value: “<<count<<endl;
}
int stat_fun::count=0; //STATIC DATA DEFINTION
void main()
{
clrscr();
cout<<“Before creation of objects:”<<endl;
stat_fun::output();
stat_fun s1,s2,s3,s4;
cout<<“After declaration of objects:”<<endl;
stat_fun::output();
getch();
}