Static member function
//static function
#include<iostream.h>
class member{
private:
static int total;
int id;
public:
member()
{total+=1;
id=total;
cout<<"creating id "<<id<<endl;
}
~member()
{
// total-=1;
id=total;
total--;
cout<<"destroying id "<<id<<endl;
}
void show()
{
cout<<"total is"<<total;}
};
int member::total=0;
int main(int argc, char *argv[])
{
member a;
member b;
member c;
member d;
// a.show();
cout<<"**********"<<endl;
}
Comments
Post a Comment