Search This Blog

Thursday, 25 October 2012

Count and static member function

#include<iostream.h>
class item{
private:
static int count;
int n;
public:
void getdata(){cout<<"get number";cin>>n;}
void getcount(){cout<<count;}
static void showcount(){cout<<count;}
};
int item::count;
void main()
{
item a,b,c;
a.getdata();
b.getdata();
c.getdata();
a.getcount();
b.getcount();
c.getcount();
item::showcount();
}
 

No comments:

Post a Comment