← Back to Pointers
Question 686
Return Locker Fields Using this->
Return Locker Fields Using this->
Complete the Locker class. It has two private int fields, lockerId and itemCount. Every parameter below has the SAME name as its field, so reach the fields through this->. 1. Constructor Locker(int lockerId, int itemCount) - store both parameters in the fields. 2.getLockerId()const - returnthis->lockerId;3.getItemCount()const - returnthis->itemCount;4.setItemCount(int itemCount)- store the parameter in the field. Do NOT write a main function - the tests supply one. The test builds Locker(12, 3) and prints its id and count, callssetItemCount(9)and prints the count again, then builds Locker(7, 0) and prints its id and count, so the output is exactly what is shown in Expected Output.
Expected Output:
12 3 9 7 0
= 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.