-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path21.1.1.cpp
59 lines (49 loc) · 965 Bytes
/
21.1.1.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
48
49
50
51
52
53
54
55
56
57
58
59
#include<iostream>
using namespace std;
// Class
class student{
// by default all members are private
string name;
public:
int age;
bool gender;
// Setter Function
void setName(string s){
name = s;
}
void getName(){
cout<<name<<endl;
}
void printInfo(){
cout<<"Name: "<<name<<", ";
cout<<"age: "<<age<<", ";
cout<<"gender: "<<gender<<" ";
cout<<endl;
}
};
int main(){
// student a;
// a.age = 12;
// a.name = "Aman";
// a.gender = true;
// cout<<a.age<<" ";
// cout<<a.name<<" ";
// cout<<a.gender<<" ";
// cout<<endl;
// Object Array
int n;
cin>>n;
student st[n];
for(int i=0; i<n; i++){
string s;
cin>>s;
st[i].setName(s);
cin>>st[i].age;
cin>>st[i].gender;
}
for(int i=0; i<n; i++){
st[i].printInfo();
}
st[0].getName();
return 0;
}