Function does not change passed pointer C++

前端 未结 4 498
北海茫月
北海茫月 2020-11-22 01:58

I have my function and I am filling targetBubble there, but it is not filled after calling this function, but I know it was filled in this function because I ha

4条回答
  •  感情败类
    2020-11-22 02:46

    You cannot change the pointer unless you pass it by (non const) reference or as a double pointer. Passing by value makes a copy of the object and any changes to the object are made to the copy, not the object. You can change the object that the pointer points to, but not the pointer itself if you pass by value.

    Have a read of this question to help understand the differences in more detail When to pass by reference and when to pass by pointer in C++?

提交回复
热议问题