Skip to content

Commit af0c31e

Browse files
Create 15publicpvt.cpp
1 parent ea60c1a commit af0c31e

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

15publicpvt.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
}

0 commit comments

Comments
 (0)