-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.cpp
More file actions
83 lines (70 loc) · 1.68 KB
/
Copy pathclass.cpp
File metadata and controls
83 lines (70 loc) · 1.68 KB
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
74
75
76
77
78
79
80
81
#include <iostream>
#include <sstream>
#include <cstring>
using namespace std;
/*
Enter code for class Student here.
Read statement for specification.
*/
class Student{
char name[51];
char surname[51];
int age;
int standard;
public:
void set_age(int ageIn);
void set_standard(int standardIn);
void set_first_name( string nameIn);
void set_last_name(string surnameIn);
int get_age();
int get_standard();
string get_first_name();
string get_last_name();
string to_str();
};
void Student::set_age(int ageIn){
age=ageIn;
}
void Student::set_standard(int standardIn){
standard=standardIn;
}
void Student::set_first_name(string nameIn){
strcpy(name ,nameIn.c_str());
}
void Student::set_last_name(string surnameIn){
strcpy(surname, surnameIn.c_str());
}
int Student::get_age(){
return age;
}
int Student::get_standard(){
return standard;
}
string Student::get_first_name(){
return name;
}
string Student::get_last_name(){
return surname;
}
string Student::to_str(){
string str1,str2;
str1= to_string(age);
str2= to_string(standard);
return str1 + "," + name + "," + surname + "," + str2;
}
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_standard(standard);
st.set_first_name(first_name);
st.set_last_name(last_name);
cout << st.get_age() << "\n";
cout << st.get_last_name() << ", " << st.get_first_name() << "\n";
cout << st.get_standard() << "\n";
cout << "\n";
cout << st.to_str();
return 0;
}