Friday, 22 March 2019

CPP-EX31

Design a class which contain static data member and member  function show() which displays number  of times display operation is performed irrespective of the object responsible for  display using static data member.


#include<iostream.h>
#include<conio.h>
class stat
{
static int n;
public:
static void show()
{
cout<<"\n Number of time call show: "<<n;
n++;
}
};
int stat::n;
void main()
{
stat s1,s2,s3,s4;
clrscr();
s1.show();
s2.show();
s3.show();
s4.show();
getch();
}