#include <iostream>
using namespace std;
class ABC
{
static int a; //a=0 internally by default
public:
void increase()
{
a++;
}
void display()
{
cout<<endl<<"a="<<a;
}
};
int ABC::a; //static member variable definition
int main()
{
ABC ob1,ob2,ob3;
ob1.increase();
ob2.increase();
ob3.increase();
ob1.display();
ob2.display();
ob3.display();
return 0;
}
using namespace std;
class ABC
{
static int a; //a=0 internally by default
public:
void increase()
{
a++;
}
void display()
{
cout<<endl<<"a="<<a;
}
};
int ABC::a; //static member variable definition
int main()
{
ABC ob1,ob2,ob3;
ob1.increase();
ob2.increase();
ob3.increase();
ob1.display();
ob2.display();
ob3.display();
return 0;
}
No comments:
Post a Comment