#include #include #include using namespace std; struct NodeT { string data; shared_ptr next; }; using PointerT = shared_ptr; void Insert(PointerT & head, string word) { PointerT tmp = make_shared(); tmp->data = word; tmp->next = head; head = tmp; } void PrintList(PointerT head) { if (head == nullptr) { cout << endl; } else { cout << head->data << " "; PrintList(head->next); } } int main() { PointerT head; for(auto word: {"Alas,","eleventy-one","years","is","far","too","short","a","time","to","live","among","such","excellent","and","admirable","hobbits."}) { Insert(head, word); } PrintList(head); return 0; }