Static Class Member in OOP
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
class counting
{
static int counte;
public :
void in()
{
counte++;
}
void out()
{
cout<<counte<<endl;
}
};
int counting :: counte;//this is must
int main()
{
counting a,b,c;
a.out();
b.out();
c.out();
a.in();
b.in();
c.in();
a.out();
b.out();
c.out();
return 0;
}
0 Comments