From 75cff007b4896eed49b758be0959668673ae1bf3 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Wed, 8 May 2024 10:07:57 +0300 Subject: [w10] Fixed mistakes in certain exercises --- week10/Exercise10/ShowableString.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'week10/Exercise10/ShowableString.cpp') 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; } -- cgit v1.2.3