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

Method addBox

Exercises/Modules/Chapter 12/Soln12_07/Truckload.cpp:114–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected