Tuesday, 2 July 2013

PROGRAM OF STATIC CLASS MEMBER FUNCTION

//STUDY OF STATIC CLASS MEMBER FUNCTION
/*MADE BY KRISHNA AGARWAL*/
#include<iostream.h>
#include<conio.h>
class item
{
    static int count;
    int number;
    public:
    void getdata(int a)
    {
        number=a;
        count++;
    }
    void getcount(void)
    {
        cout<<" count\t"<<count<<"\n";
    }
};
int item::count;
void main()
{
    clrscr();
    item a,b,c;
    a.getcount();
    b.getcount();
    c.getcount();
    a.getdata(100);
    b.getdata(200);
    c.getdata(300);
    cout<<"after reading data\n";
    a.getcount();
    b.getcount();
    c.getcount();
    getch();
}

No comments:

Post a Comment