From fc6fc4032b54a5a8a8aababa3d5f16f8b5595507 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sat, 20 Nov 2021 22:50:05 +0000 Subject: (list)+simple output mechanism via C++ streams cout has inbuilt support for multiple types, easier than using printf. Just have to ease the compiler into it --- list.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/list.cpp b/list.cpp index 937e7a7..009ed9a 100644 --- a/list.cpp +++ b/list.cpp @@ -4,6 +4,7 @@ */ #include +#include #include template @@ -34,6 +35,15 @@ List *append(List *lst, T value) return lst; } +template +std::ostream& operator<<(std::ostream& ostream, const List *lst) +{ + if (lst == NULL) + return ostream; + ostream << "|" << lst->value << lst->next; + return ostream; +} + int main(void) { return 0; -- cgit v1.2.3-13-gbd6f