C++ Program using Static Class Member:
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class item
{
static int count;
int number;
public:
void getdata(int a)
{
number=a;
count++;
}
void getcount(void)
{
cout<<"Count=";
cout<<count<<"\n";
}
};
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<<"After reading data"<<"\n";
a.getcount();
b.getcount();
c.getcount();
getch();
}
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class item
{
static int count;
int number;
public:
void getdata(int a)
{
number=a;
count++;
}
void getcount(void)
{
cout<<"Count=";
cout<<count<<"\n";
}
};
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<<"After reading data"<<"\n";
a.getcount();
b.getcount();
c.getcount();
getch();
}
0 comments:
Post a Comment