diff options
Diffstat (limited to 'week10/Exercise10/ShowableString.cpp')
| -rw-r--r-- | week10/Exercise10/ShowableString.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/week10/Exercise10/ShowableString.cpp b/week10/Exercise10/ShowableString.cpp index 1231a9c..09dbd51 100644 --- a/week10/Exercise10/ShowableString.cpp +++ b/week10/Exercise10/ShowableString.cpp @@ -1,9 +1,13 @@ #include "ShowableString.h" std::ostream& operator<<(std::ostream& ostr, const ShowableString& str) { - return ostr << str; + return ostr << str.str; } -std::istream& operator>>(std::istream& istr, const ShowableString& str) { - return istr >> str; // Лошо! +std::istream& operator>>(std::istream& istr, ShowableString& str) { + unsigned size; + istr >> size; + str.free(); + str.str = new char[size]; + return istr >> str.str; } |
