-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path10_Encapsulation.cpp
47 lines (37 loc) · 956 Bytes
/
10_Encapsulation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<iostream>
using namespace std;
class student{
private:
string studentname;
int studentRollNo;
int studentAge;
public:
string getstudentName(){
return studentname;
}
void setStudentName(string studentname){
this ->studentname=studentname;
}
int getRollNo(){
return studentRollNo;
}
void setStudentRollNo(int studentRollNo){
this-> studentRollNo=studentRollNo;
}
int getStudentAge(){
return studentAge;
}
void setStudentAge(int studentAge){
this-> studentAge=studentAge;
}
};
int main(){
student obj;
obj.setStudentName("danish");
obj.setStudentRollNo(30);
obj.setStudentAge(19);
cout<<"Student Name : "<<obj.getstudentName()<<endl;
cout<<"Student RollNo : "<<obj.getRollNo()<<endl;
cout<<"Student Age : "<<obj.getStudentAge()<<endl;
return 0;
}