MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / push

Method push

Examples/NoModules/Chapter 17/Ex17_04A/Stack.h:72–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70// Push an object onto the stack
71template <typename T>
72void Stack<T>::push(const T& item)
73{
74 Node* node{ new Node{item} }; // Create the new node
75 node->m_next = m_head; // Point to the old top node
76 m_head = node; // Make the new node the top
77}
78
79// Pop an object off the stack
80template <typename T>

Callers 1

mainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected