Less memory methods

If i have the following methods: void addfive(int num) { num = num + 5; } and when i use it in the main routine like this: int a = 15; addfive(a); What will happen is that 5 will be added to a copy of the (a) variable. but if the method parameter is a pointer `int* num` instead of the `int num 5` will be added to the (a) variable and no copy is created. If I used the pointer in my method, will this use less memory that the first method, and will this work in non_void methods?
Is there any particular reason why you don't use a reference (int &num) [assuming C++]?

以上就是Less memory methods的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准