#include #include template struct Node { T data; Node* next; }; template void push(Node*& head, T d) { head = new Node{d, head}; } template T pop(Node*& head) { T d{head->data}; Node* n{head->next}; delete head; head = n; return d; } template bool empty(Node* head) { return head == nullptr; } int main() { // "something"s is now a literal of type std::string using namespace std::literals; Node* headI{nullptr}; Node* headS{nullptr}; push(headI, 3); push(headS, "3"s); push(headI, 2); push(headS, "2"s); push(headI, 1); push(headS, "1"s); push(headS, "0"s); while(!empty(headI)) std::cout << pop(headI) << " "; std::cout << std::endl; while(!empty(headS)) std::cout << pop(headS) << " "; std::cout << std::endl; }