-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathP92OOPS.cpp
More file actions
61 lines (46 loc) · 980 Bytes
/
P92OOPS.cpp
File metadata and controls
61 lines (46 loc) · 980 Bytes
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
60
61
// OOPS
// class
#include<iostream>
using namespace std;
class student{
//string name; it is in private to access this we can use set func
public:
string name;
int age;
bool gender;
void setName(string s){ // setter function
name=s;
}
void getName(){ // get function
cout<<name<<endl;
}
void printInfo(){
cout<<"name: ";
cout<<name<<endl;
cout<<"age: ";
cout<<age<<endl;
cout<<"gender: ";
cout<<gender<<endl;
}
};
int main(){
student arr[3];
for (int i = 0; i < 3; i++)
{
// string s;
// cout<<"name: ";
// cin>>s;
// arr[i].setName(s);
cout<<"name: ";
cin>>arr[i].name;
cout<<"age: ";
cin>>arr[i].age;
cout<<"gender: ";
cin>>arr[i].gender;
}
for (int i = 0; i < 3; i++)
{
arr[i].printInfo();
}
return 0;
}