Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Generic
diff options
context:
space:
mode:
Commitf4f97bd1c9a40428695c3ac0a387bb50b6dce1c4 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-07 19:39:09 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-07 19:39:09 +0300
Files7262bcfbb21c8097f0e66c90942fd1f00f658052 /src/Generic
FMI-OOP-P1_TicketSystem-f4f97bd1c9a40428695c3ac0a387bb50b6dce1c4.tar
FMI-OOP-P1_TicketSystem-f4f97bd1c9a40428695c3ac0a387bb50b6dce1c4.tar.gz
FMI-OOP-P1_TicketSystem-f4f97bd1c9a40428695c3ac0a387bb50b6dce1c4.zip
Parent9a96a3ff932312e4e00baf496b744807f0e171f1 (diff)
Autocommit at 07.05.2022 @ 19:39
1 files changed, 9 insertions, 9 deletions
-rw-r--r--src/Generic/List/List.hpp18
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<T>& obj);
- friend std::ostream& operator<<(std::ostream& ostr, const List<T>& obj);
};
template <typename T>
@@ -234,19 +231,22 @@ List<T>& List<T>::operator=(List&& other) {
template <typename T>
std::istream& operator>>(std::istream& istr, List<T>& obj) {
- istr >> obj.length >> obj.count;
-
- delete[] obj.elements;
- obj.elements = new T[obj.length];
+ List<T> 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 <typename T>
std::ostream& operator<<(std::ostream& ostr, const List<T>& obj) {
+ ostr << obj.get_count() << " ";
for (int i = 0; i < obj.count; i++)
ostr << obj.elements[i];