/*
Static Data Member
*/
#include<iostream>
#include<conio.h>
using namespace std;
class Sample
{
int code;
static int count;
public:
void accept()
{
count++;
code=count;
}
void display()
{
cout<<"\n Object Number: "<<code;
}
};
int Sample ::count;
int main()
{
Sample s1,s2,s3;
cout<<"\n\n Before Accept call: ";
s1.display();
s2.display();
s3.display();
s1.accept();
s2.accept();
s3.accept();
cout<<"\n\n After Accept call: ";
s1.display();
s2.display();
s3.display();
getch();
return 0;
}
Static Data Member
*/
#include<iostream>
#include<conio.h>
using namespace std;
class Sample
{
int code;
static int count;
public:
void accept()
{
count++;
code=count;
}
void display()
{
cout<<"\n Object Number: "<<code;
}
};
int Sample ::count;
int main()
{
Sample s1,s2,s3;
cout<<"\n\n Before Accept call: ";
s1.display();
s2.display();
s3.display();
s1.accept();
s2.accept();
s3.accept();
cout<<"\n\n After Accept call: ";
s1.display();
s2.display();
s3.display();
getch();
return 0;
}