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

Method addBox

Exercises/Modules/Chapter 12/Soln12_08/Truckload.cpp:119–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119void Truckload::addBox(SharedBox box)
120{
121 auto package{ new Package{box} }; // Create a new Package
122
123 if (m_tail) // Check list is not empty
124 {
125 package->m_previous = m_tail; // The package is added after the old tail
126 m_tail->m_next = package; // Append the new object to the tail
127 }
128 else // List is empty
129 m_head = package; // so new object is the head
130
131 m_tail = package; // Either way: the latest object is the (new) tail
132}
133
134bool Truckload::removeBox(SharedBox boxToRemove)
135{

Callers 1

mainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected