using namespace std;
class stat
{static int count;
public:
int a;
void getdata()
{
cout<< "enter no";
cin>>a;
cout<< a;
count++;
}
void showdata()
{
cout<< "count is"<< count< <endl;
}};
int stat::count=0;
int main()
{int i;
stat a;
a.showdata();
for(i=0;i<4;i++)
{
a.getdata();
a.showdata();
}
}
An important detail to keep in mind when debugging or implementing a program using a static class member is that you cannot initialize the static class member inside of the class.
No comments:
Post a Comment
SAY HELLO!!