File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Online C++ compiler to run C++ program online
2
+ #include < bits/stdc++.h>
3
+ using namespace std ;
4
+ class student {
5
+ string name;
6
+ public:
7
+ int age;
8
+ bool gender;
9
+
10
+ void setName (string s){
11
+ name=s;
12
+ }
13
+
14
+ void printInfo (){
15
+ cout<<" Name=" ;
16
+ cout<<name<<endl;
17
+ cout<<" Age=" ;
18
+ cout<<age<<endl;
19
+ cout<<" Gender=" ;
20
+ cout<<gender<<endl;
21
+ }
22
+
23
+ };
24
+ int main () {
25
+
26
+ // student a;
27
+ // a.name="Tim";
28
+ // a.age=18;
29
+ // a.gender=1;
30
+ // a.printInfo();
31
+
32
+ student arr[3 ];
33
+ for (int i=0 ;i<3 ;i++){
34
+ string s;
35
+ cout<<" Name=" ;
36
+ cin>>s;
37
+ arr[i].setName (s);
38
+ cout<<" Age=" ;
39
+ cin>>arr[i].age ;
40
+ cout<<" Gender=" ;
41
+ cin>>arr[i].gender ;
42
+ }
43
+ for (int i=0 ;i<3 ;i++){
44
+ arr[i].printInfo ();
45
+ }
46
+
47
+
48
+ return 0 ;
49
+ }
You can’t perform that action at this time.
0 commit comments