(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
This commit is contained in:
10
list.cpp
10
list.cpp
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <iostream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -34,6 +35,15 @@ List<T> *append(List<T> *lst, T value)
|
|||||||
return lst;
|
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)
|
int main(void)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user