-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathE0013.cpp
73 lines (60 loc) · 1.36 KB
/
E0013.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
Problem Statement: https://www.hackerrank.com/challenges/c-tutorial-class/problem
*/
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
class Student {
private:
int age, standard;
string first_name, last_name;
public:
Student(int age, string first_name, string last_name, int standard) {
this->age = age;
this->first_name = first_name;
this->last_name = last_name;
this->standard = standard;
}
int get_age() {
return age;
}
void set_age(int age) {
this->age = age;
}
string get_first_name() {
return first_name;
}
void set_first_name(string first_name) {
this->first_name = first_name;
}
string get_last_name() {
return last_name;
}
void set_last_name(string last_name) {
this->last_name = last_name;
}
int get_standard() {
return standard;
}
void set_standard(int standard) {
this->standard = standard;
}
string to_string() {
ostringstream ss;
ss << age << ',' << first_name << ',' << last_name << ',' << standard;
return ss.str();
}
};
int main() {
int age, standard;
string first_name, last_name;
cin >> age >> first_name >> last_name >> standard;
Student S(age, first_name, last_name, standard);
cout << S.get_age() << endl;
cout << S.get_last_name() << ", " << S.get_first_name() << endl;
cout << S.get_standard() << endl;
cout << endl;
cout << S.to_string() << endl;
return 0;
}