C++ Programming Blog

 
 
 
#include<iostream.h>
#include<conio.h>
class stat
{
    static int 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();
    }
}

 
 
Didn't find what you were looking for? Find more on Program that provides an example of static variables in class