#include<iostream>
using namespace std;
class Employee{
private:
int a,b,c ;
public:
int d,e;
void setdata(int a1, int b1, int c1);
void getdata(){
cout<<"The value of a is : "<<a<<endl;
cout<<"The value of b is : "<<b<<endl;
cout<<"The value of c is : "<<c<<endl;
cout<<"The value of d is : "<<d<<endl;
cout<<"The value of e is : "<<e<<endl;
}
};
void Employee :: setdata(int a1, int b1, int c1){
a=a1;
b=b1;
c=c1;
}
int main(){
Employee Ramesh ;
// Ramesh.a=10; ----> It shows error because we can not change private variables directly
// Ramesh.b=20; ----> It shows error because we can not change private variables directly
// Ramesh.c=30; ----> It shows error because we can not change private variables directly
Ramesh.d=4;
Ramesh.e=5;
Ramesh.setdata(1,2,3);
Ramesh.getdata();
return 0;
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.