CJCoding With Joseph
15free / daySign inCreate account
← Back to Question List

Select topics to narrow your question pool, then enable Random to jump to a random question matching your filters.

Topics:
C++ Quiz #110

Which Destructor Fits the Relationship?

mediumPointers

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 new
3 size_t m_count;
4 // ...
5};
6 
7class 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};