-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01_class.cpp
55 lines (48 loc) · 1.47 KB
/
01_class.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
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#include <sstream>
class Student{
private:
int age;
string first_name;
string last_name;
int standard;
public:
void set_age(const int& age) { this->age = age; }
int get_age() { return age; }
void set_first_name(const string &name) { first_name = name; }
string get_first_name() { return first_name; }
void set_last_name(const string &name) { last_name = name; }
string get_last_name() { return last_name; }
void set_standard(const int &standard) { this->standard = standard; }
int get_standard() { return standard; }
string to_string(){
stringstream ss;
ss << age << "," << first_name << "," << last_name << "," << standard;
return ss.str();
}
};
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
Student obj;
string str;
int n;
cin >> n;
obj.set_age(n);
cin >> str;
obj.set_first_name(str);
cin >> str;
obj.set_last_name(str);
cin >> n;
obj.set_standard(n);
cout << obj.get_age() << endl;
cout << obj.get_last_name() << ", " << obj.get_first_name() << endl;
cout << obj.get_standard() << endl;
cout << endl;
cout << obj.to_string() << endl;
return 0;
}