This is a very simple problem however for whatever reason, I cannot get this to work. Whenever I pass an argument to my function it doesn’t get updated.
Hi! The thing is that you pass param by Value. Roughly speaking, function copy argument in it’s stack frame and works with this local variable. What you need to do is - to pass param by Reference or by Pointer. To do so, just update you function declaration and implementation
Ah, that makes sense. Thank you so much. But in which case should I use a pointer over a reference or the other way round. Can you also make this an answer so I can mark the question as answered. Thanks again.
For function parameters - use reference most time, when you can. You dont need to care about nullptr in this case, so reference are way more safe. And only if you cant use reference - use pointer. But, of course, there are other rules for simple and effective C++ code that are more important. For example, try to minimize header file , that is included in many other headers. This make total build size smaller. Another example - to avoid circular dependencies between headers you can use pointers and forward declarations.