CJCoding With Joseph
15free / daySign inCreate account

Order owns a heap array of quantities through the simple pointer m_quantities (one pointer, one array, one delete[]) and also has a plain string m_customer; an order whose customer is empty is INVALID and print says so. Write the move constructor and the move assignment operator (both noexcept):

- take the customer with std::move(other.m_customer), take over the array pointer and the count - then make the source invalid on purpose: clear other.m_customer (do not rely on what std::move leaves behind), set its pointer to nullptr and its count to 0 - the assignment operator must do nothing when the source is this object, release the array it already holds before taking over, and return *this

Write every loop inside the special member that needs it; do not add private helper functions.

The driver reads a customer and a count, then that many quantities. It move-constructs a second order from the first and prints both, move-assigns the second into an order built for Omar with one quantity and prints both, then move-assigns the result to itself through a reference and prints it. A valid order prints as Order for CUSTOMER: followed by a space and each quantity.

For the input:

Mina 3
2 4 1

the 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

Invalid order
Order for Mina: 2 4 1
Invalid order
Order for Mina: 2 4 1
Order for Mina: 2 4 1

= newline. The output ends with a newline, so print one after the last line.

Hints4 available
Topics
Pointers
Auto-input
Mina 3\n2 4 1\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.