Pass it by reference. Something like void myFunc(queue& q). This will pass the address of the queue so it is efficient. It is better than passing a pointer to the queue because myFunc() does not have to worry about it being a null pointer.
Push to a queue passed as a function parameter
-
07-07-2023 - |
Вопрос
I'm trying to push
to a queue
inside of a function called in multiple places.
From my limited experience, if I pass the queue
as is, I think it will be a copy, so only the copy will be push
ed.
How can the original queue
be passed as a function parameter and push
ed inside the function?
Решение
Не связан с StackOverflow