-
Notifications
You must be signed in to change notification settings - Fork 0
/
Class(problem 2).cpp
70 lines (66 loc) · 1.31 KB
/
Class(problem 2).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
#include <iostream>
using namespace std;
class Student
{
int age;
string first_name,last_name;
int standard;
public:
void set_age(int a)
{
age = a;
}
int get_age()
{
return age;
}
void set_first_name(string fn)
{
first_name = fn;
}
string get_first_name()
{
return first_name;
}
void set_last_name(string ln)
{
last_name = ln;
}
string get_last_name()
{
return last_name;
}
void set_standard(int s)
{
standard = s;
}
int get_standard()
{
return standard;
}
string to_string()
{
string result;
result += std::to_string(age) + ",";
result += first_name + ",";
result += last_name + ",";
result += std::to_string(standard);
return result;
}
};
int main()
{
int age, standard;
string first_name, last_name;
cin >> age >> first_name >> last_name >> standard;
Student st;
st.set_age(age);
st.set_first_name(first_name);
st.set_last_name(last_name);
st.set_standard(standard);
cout <<endl<< st.get_age() << endl;
cout << st.get_last_name() << ", " << st.get_first_name() << endl;
cout << st.get_standard() << endl<<endl;
cout << st.to_string() << endl;
return 0;
}