The addItem function takes an argument of type Item* , and the pointer is passed by reference. This means that the addItem function can internally change the pointer. It may also mean that the object is being redistributed or changed inside this function.
Example:
void pointerByValue(int* ptr) { ptr = new int[10]; } void pointerByReference(int*& ptr) { ptr = new int[10]; } void main() { int* p = NULL;
The pointer by reference is valid only in C ++.
source share