File tree 2 files changed +7
-6
lines changed
2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 14
14
class Person {
15
15
std::string name;
16
16
std::string address;
17
-
18
- std::string getName () const { return name; }
19
- std::string getAddress () const { return address; }
17
+ public:
18
+ const std::string& getName () const { return name; }
19
+ const std::string& getAddress () const { return address; }
20
20
};
21
21
22
22
#endif
Original file line number Diff line number Diff line change 13
13
#include < iostream>
14
14
15
15
struct Person {
16
- std::string getName () const { return name; }
17
- std::string getAddress () const { return address; }
18
-
16
+ const std::string& getName () const { return name; }
17
+ const std::string& getAddress () const { return address; }
18
+
19
19
std::string name;
20
20
std::string address;
21
21
};
22
22
23
23
std::istream &read (std::istream &is, Person &person)
24
24
{
25
25
is >> person.name >> person.address ;
26
+ if (!is) person = Person ();
26
27
return is;
27
28
}
28
29
You can’t perform that action at this time.
0 commit comments