Program -
#include<iostream.h>
#include<conio.h>
#include<dos.h>
class stu
{
private:
static int c;
public:
stu();
static void
write();
};
int stu::c=0;
stu::stu()
{
c++;
}
void stu::write()
{
cout<<"final
value of c"<<c<<endl;
}
void main()
{
cout<<"before
understanding object"<<endl;
stu::write();
stu
m1,m2,m3,m4,m5;
cout<<"after
the understanding of object"<<endl;
stu::write();
getch();
}
Output :
before
understanding object
final value of c
0
after the
understanding of object
final value of c
5
0 comments:
Post a Comment