/* C++ program to count member funtion calls */
#include<iostream>
using namespace std;
class A
{
int data;
static int i,j;
public:
void input()
{
cout<<"enter num : ";
cin>>data;
i++;
}
void display()
{
cout<<"\nnum is "<<data<<endl;
j++;
}
void count()
{
cout<<"\nInput calls = "<<i<<"\nDisplay calls = "<<j<<endl;
}
};
int A :: i=0;
int A :: j=0;
int main()
{
A A1;
int c;
do
{
cout<<"\n1.INPUT\n2.OUTPUT\n3.COUNT\n4.EXIT\nENTER CHOICE : ";
cin>>c;
switch(c)
{
case 1:
A1.input();
break;
case 2:
A1.display();
break;
case 3:
A1.count();
break;
default :
return 0;
}
}
while(c);
return 0;
}
#include<iostream>
using namespace std;
class A
{
int data;
static int i,j;
public:
void input()
{
cout<<"enter num : ";
cin>>data;
i++;
}
void display()
{
cout<<"\nnum is "<<data<<endl;
j++;
}
void count()
{
cout<<"\nInput calls = "<<i<<"\nDisplay calls = "<<j<<endl;
}
};
int A :: i=0;
int A :: j=0;
int main()
{
A A1;
int c;
do
{
cout<<"\n1.INPUT\n2.OUTPUT\n3.COUNT\n4.EXIT\nENTER CHOICE : ";
cin>>c;
switch(c)
{
case 1:
A1.input();
break;
case 2:
A1.display();
break;
case 3:
A1.count();
break;
default :
return 0;
}
}
while(c);
return 0;
}
No comments:
Post a Comment