diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2021-11-20 22:50:05 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2021-11-20 22:50:05 +0000 |
commit | fc6fc4032b54a5a8a8aababa3d5f16f8b5595507 (patch) | |
tree | 2e59cc2c79c0b04123a935792292d173ed792dae | |
parent | fccfcd4a9f51f9d97a693a9b301157a9aa88db6f (diff) | |
download | algorithms-fc6fc4032b54a5a8a8aababa3d5f16f8b5595507.tar.gz algorithms-fc6fc4032b54a5a8a8aababa3d5f16f8b5595507.tar.bz2 algorithms-fc6fc4032b54a5a8a8aababa3d5f16f8b5595507.zip |
(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
-rw-r--r-- | list.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -4,6 +4,7 @@ */ #include <cstdio> +#include <iostream> #include <cstdlib> template <typename T> @@ -34,6 +35,15 @@ List<T> *append(List<T> *lst, T value) return lst; } +template <typename T> +std::ostream& operator<<(std::ostream& ostream, const List<T> *lst) +{ + if (lst == NULL) + return ostream; + ostream << "|" << lst->value << lst->next; + return ostream; +} + int main(void) { return 0; |