#include <iostream> using namespace std; template <class T> class Node { public: T data; Node<T> * next; Node<T> (T d, Node<T> * n) :data(d), next(n) { } T printAndSum() { cout << data << endl; if (next == NULL) return data; else return data + next->printAndSum(); } }; int main() { Node<float>* fhead = NULL; Node<int>* ihead = NULL; float x; while (cin >> x) { fhead = new Node<float>(x, fhead); ihead = new Node<int>((int)x, ihead); } cout << "Floating sum: " << fhead->printAndSum() << endl << endl; cout << "Int sum: " << ihead->printAndSum() << endl << endl; return 0; }