From f4f97bd1c9a40428695c3ac0a387bb50b6dce1c4 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 7 May 2022 19:39:09 +0300 Subject: Autocommit at 07.05.2022 @ 19:39 --- src/Generic/List/List.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/Generic') diff --git a/src/Generic/List/List.hpp b/src/Generic/List/List.hpp index d4385e2..b4c3b73 100644 --- a/src/Generic/List/List.hpp +++ b/src/Generic/List/List.hpp @@ -40,9 +40,6 @@ public: List(List&& other); List& operator=(List&& other); - - friend std::istream& operator>>(std::istream& istr, List& obj); - friend std::ostream& operator<<(std::ostream& ostr, const List& obj); }; template @@ -234,19 +231,22 @@ List& List::operator=(List&& other) { template std::istream& operator>>(std::istream& istr, List& obj) { - istr >> obj.length >> obj.count; - - delete[] obj.elements; - obj.elements = new T[obj.length]; + List newObj; + unsigned count; + istr >> count; - for (int i = 0; i < obj.count; i++) - istr >> obj.elements[i]; + T temp; + for (int i = 0; i < count; i++) { + istr >> temp; + obj.add(temp); + } return istr; } template std::ostream& operator<<(std::ostream& ostr, const List& obj) { + ostr << obj.get_count() << " "; for (int i = 0; i < obj.count; i++) ostr << obj.elements[i]; -- cgit v1.3.1-26-gb76a