#include
class test
{
int code;
static int count;
public:
void setcode(void)
{
code=++count;
}
void showcode(void)
{
cout<<"Object Number:"<< code<<"\n";
}
static void showcount(void)
{
cout<<"\ncount:"<< count;
}
};
int test :: count;
void main()
{
clrscr();
t1.setcode();
t2.setcode();
test::showcount();
test t3;
t3.setcode();
test::showcount();
t1.showcode();
t2.showcode();
t3.showcode();
getch();
}
Output will be
Count: 3
Object Number: 1
Object Number: 2
Object Number: 3
No comments:
Post a Comment