File tree Expand file tree Collapse file tree 2 files changed +3
-11
lines changed Expand file tree Collapse file tree 2 files changed +3
-11
lines changed Original file line number Diff line number Diff line change @@ -7,16 +7,8 @@ void Student::setAge(int age) { this->age = age; }
7
7
void Student::setAge (short age) { this ->age = age; }
8
8
void Student::setAge (unsigned short age) { this ->age = age; }
9
9
10
- void Student::setName (std::string &name) {
11
- if (name.length () < 50 ) {
12
- std::strcpy (this ->name , name.c_str ());
13
- }
14
- }
15
- void Student::setName (const char *name) {
16
- if (std::strlen (name) < 50 ) {
17
- std::strcpy (this ->name , name);
18
- }
19
- }
10
+ void Student::setName (std::string &name) { this ->name = name; }
11
+ void Student::setName (const char *name) { this ->name = std::string (name); }
20
12
21
13
std::string Student::whoami () const {
22
14
std::stringstream s;
Original file line number Diff line number Diff line change 2
2
3
3
class Student {
4
4
private:
5
- char name[ 50 ] ;
5
+ std::string name;
6
6
unsigned short age;
7
7
8
8
public:
You can’t perform that action at this time.
0 commit comments