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

Method push

Examples/NoModules/Chapter 17/Ex17_04B/Stack.h:75–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73// Push an object onto the stack
74template <typename T>
75void Stack<T>::push(const T& item)
76{
77 // See Chapter 18 for std::move()
78 auto node{ std::make_unique<Node>(item) }; // Create the new node
79 node->m_next = std::move(m_head); // Point to the old top node
80 m_head = std::move(node); // Make the new node the top
81}
82
83// Pop an object off the stack
84template <typename T>

Callers 1

mainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected