PROGRAM FOR STATIC DATA MEMBER

//program for static data member
#include<iostream.h>
#include<conio.h>
class item
{
  static int count;
  int n;
  public:
  void getdata(int a)
  {
    n=a;
    count++;
  }
  void getcount()
  {
     cout<<endl<<"count="<<count;
  }
};
int item::count;
void main()
{
  item a,b,c;
  clrscr();
  a.getcount();
  b.getcount();
  c.getcount();
  a.getdata(100);
  b.getdata(200);
  c.getdata(300);
  cout<<endl<<"after reading daTA:";
  a.getcount();
  b.getcount();
  c.getcount();
  getch();
}


Comments

Popular Posts