source file name: staticfn.cpp

 #include<conio.h>

#include<iostream.h>

class STest

{

static int cnt;

int data;

public:

void setno()

{

data=++cnt;

}

void showdata()

{

cout<<" object number: "<<data<<endl;

}

static void display()

{

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

}

};

int STest::cnt;

void main()

{

clrscr();

cout<<"Program on static Function"<<endl;

STest ob1, ob2,ob3;

ob1.setno();

ob2.setno();

ob3.setno();

STest::display();

   STest ob4;

   ob4.setno();

STest::display();

   ob1.showdata();

   ob2.showdata();

   ob3.showdata();

   ob4.showdata();

getch();

}

output: