什么是ref函数传递? [英] what is pass by ref function?

查看:124
本文介绍了什么是ref函数传递?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我刚才有这种怪异的怀疑....我有以下的代码,

hi all,
I just got this freaky kind of doubt....I have the following piece of code,

展开 | 选择 | Wrap | 行号

推荐答案

C仅使用pass by value;即使将指针作为参数传递,该指针的

值也会传递给该函数。 C ++也有一个参考传递

机制,但这不是你在你的示例代码中使用的。


亲切的问候,


Jos
C uses pass by value only; even when you pass a pointer as a parameter, the
value of that pointer is passed to the function. C++ also has a pass by reference
mechanism but that''s not what you''re using in your example code.

kind regards,

Jos


感谢Jos的回复。


所以你的意思是,如果我使用相同的在C ++中的代码,它也可以用作引用传递。如果是的话,您能否向我简要介绍一下如何处理机制或我可以寻找答案的位置......
Thanks for the reply Jos.

So you mean here that if I use the same code in C++, then it can be used as pass by reference also. If yes, can you just brief me about the mechanism how it is handled or some location where I can look for answers....



感谢Jos的回复。


所以你的意思是,如果我在C ++中使用相同的代码,那么它也可以作为参考传递使用。如果是的话,您能否向我简要介绍一下如何处理它的机制或我可以寻找答案的位置....
Thanks for the reply Jos.

So you mean here that if I use the same code in C++, then it can be used as pass by reference also. If yes, can you just brief me about the mechanism how it is handled or some location where I can look for answers....





在C中,指针也占据内存中的某个位置来存储地址。

在C ++中有一些叫做引用类型的东西。这就像为变量赋予别名/新名称。

Hi,
In C, pointers also occupy some place in the memory to store the address.
In C++ there is something called reference type. This is just like giving an alias/ new name to the variable.

展开 | 选择 | Wrap | 行号


这篇关于什么是ref函数传递?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆