Code for Program that provides an example of static variables in class in C++ Programming
#include<iostream.h>
#include<conio.h>
class stat
{
staticint count;
int no;
public:
void cnt()
{
cout<<"Count = "<<count<<endl;
count++;
}
void num()
{
no=1;
cout<<"Number is = "<<no<<endl;
}
};
int stat::count=1;
main()
{
clrscr();
stat d,e;
for(int i=0;i<5;i++)
{
d.cnt();
e.num();
}
}