← Back to Question List
C++ Quiz #110
Which Destructor Fits the Relationship?
Both classes manage a dynamically allocated array of const Part*. Kit's constructor fills its array with new Part(*parts[i]), so every slot points at a Part the Kit created. PickList::operator+= stores &part, the address of a Part that lives in main(). Which pair of destructors is correct?
📄 Code
1class Kit {2 const Part** m_parts; // each slot points at a Part this Kit created with new3 size_t m_count;4 // ...5};67class PickList {8 const Part** m_parts; // each slot holds the address of a Part that lives in main()9 size_t m_count;10 // ...11};