Inventory Copy Constructor Deep-Copies the Names
easyQuestion 732Inventory is written for you except its copy constructor. m_items is a simple pointer: it holds the address of the first string in ONE heap array, so the whole array is released with a single delete[]. Write Inventory(const Inventory& other) so the new object gets its OWN array of the same size with every name copied across in a loop; afterwards changing one inventory must never change the other.
The hidden driver reads n followed by n item names (one per line), copy-constructs a second inventory from the first, renames the copy's first item to CHANGED, prints both lists with each name in square brackets, then prints separate if slot 0 of the two objects lives at different addresses (or shared if not).
For the input:
3
Hammer
Nail Box
Sawthe exact output is what is shown in Expected Output.
Free the memory you allocate — this question checks for memory leaks.
Do NOT write a main function.
Expected output
original: [Hammer] [Nail Box] [Saw] copy: [CHANGED] [Nail Box] [Saw] separate
= newline. The output ends with a newline, so print one after the last line.
Your output
Run your code to see the output here...