//give numbers
#include<iostream.h>
#include<conio.h>
class test
{
private:
static int count;
public:
test() //constructor
{
count++;
}
int getcount() // member function
{
return count;
}
};
int test::count=0;
void main()
{
test t1;
cout<<"count is :"<<t1.getcount()<<endl;;
test t2;
cout<<"count is :"<<t2.getcount()<<endl;
test t3;
cout<<"count is :"<<t3.getcount();
getch();
}
#include<iostream.h>
#include<conio.h>
class test
{
private:
static int count;
public:
test() //constructor
{
count++;
}
int getcount() // member function
{
return count;
}
};
int test::count=0;
void main()
{
test t1;
cout<<"count is :"<<t1.getcount()<<endl;;
test t2;
cout<<"count is :"<<t2.getcount()<<endl;
test t3;
cout<<"count is :"<<t3.getcount();
getch();
}
0 comments:
Post a Comment