//This tut contains Static Data Members & Methods in C++ OOPS
#include<iostream>
using namespace std;
class Employee
{
int id;
static int count;1
public:
void setData(void)
{
cout<<"Enter the Id of employee :"<<endl;
cin>>id;
}
void getData(void)
{
cout<<"The Id is "<<id<<" of employee no "<<count<<endl;
count++;
}
static void getCount(void)
{
cout<<"The count is "<<count<<endl;
}
};
int Employee :: count;
int main(){
Employee harry,rocky,john;
harry.setData();
harry.getData();
Employee :: getCount();
rocky.setData();
rocky.getData();
Employee :: getCount();
john.setData();
john.getData();
Employee :: getCount();
return 0;
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.