// An Example Taken in Classroom
#include<iostream.h>
#include<conio.h>
class gamma
{
private:
static
int total;
int id;
public:
gamma()
{
total++;
id = total;
}
~gamma()
{
total--;
cout << "\n Destroying ID no = " << id;
}
static
void showtotal()
{
cout << "\nTotal is " << total;
}
void showid()
{
cout << "\n ID is " << id;
}
};
int gamma::total;
void main()
{
clrscr();
cout << endl << endl ;
gamma::showtotal();
gamma g1;
gamma::showtotal();
gamma g2, g3;
gamma::showtotal();
g1.showid();
g2.showid();
g3.showid();
cout << "\n................... End of Program";
getch();
}
No comments:
Post a Comment