← Back to Pointers
Question 736
AudioClip Move Constructor Steals the Samples
AudioClip Move Constructor Steals the Samples
AudioClipis written for you except its move constructor.m_samplesis a simple pointer to ONE heap array of ints. WriteAudioClip(AudioClip&& other) noexceptso the new clip takes over the other clip's array and count, and the other clip is left withnullptrand a count of 0 (so its destructor frees nothing and it reports zero samples). Moving copies one pointer; no sample is copied. The hidden driver readsnthennsample values into a clip, move-constructs a second clip from it withstd::move, and prints the second clip's size, first and last sample on one line, then the source clip's size on the next. For the input: ``3 7 8 9`` 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:
moved: 3 samples, first 7, last 9 source: 0 samples
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Pointers
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.