Skip to content

Commit ea60c1a

Browse files
Create 14classes.cpp
1 parent 89d58b0 commit ea60c1a

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

14classes.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Online C++ compiler to run C++ program online
2+
#include <bits/stdc++.h>
3+
using namespace std;
4+
class student{
5+
public:
6+
string name;
7+
int age;
8+
bool gender;
9+
10+
void printInfo(){
11+
cout<<"Name=";
12+
cout<<name<<endl;
13+
cout<<"Age=";
14+
cout<<age<<endl;
15+
cout<<"Gender=";
16+
cout<<gender<<endl;
17+
}
18+
19+
};
20+
int main() {
21+
22+
// student a;
23+
// a.name="Tim";
24+
// a.age=18;
25+
// a.gender=1;
26+
// a.printInfo();
27+
28+
student arr[3];
29+
for(int i=0;i<3;i++){
30+
cout<<"Name=";
31+
cin>>arr[i].name;
32+
cout<<"Age=";
33+
cin>>arr[i].age;
34+
cout<<"Gender=";
35+
cin>>arr[i].gender;
36+
}
37+
for(int i=0;i<3;i++){
38+
arr[i].printInfo();
39+
}
40+
41+
42+
return 0;
43+
}

0 commit comments

Comments
 (0)