将引用转换为C ++中的指针表示 [英] convert reference to pointer representation in C++
本文介绍了将引用转换为C ++中的指针表示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有一种方法来转换指针在c ++中的引用?在下面的例子中, func
已经定义了原型,我不能改变它,但 func
是我的API,我想传递这两个参数,或者一个(和第二个设置为NULL)或两者(都设置为NULL):
Is there a way to "convert" a reference to pointer in c++? In example below, func
has already defined prototype and I can't change it, but func
is my API, and I'd like to either pass both parameters, or one (and second set to NULL) or neither (both set to NULL):
void func2(some1 *p1, some2 *p2);
func(some1& obj, some2& obj2)
{
func2(..);
}
推荐答案
func2(& obj,& obj2);
使用参考参数,如正常变量。
Use reference parameters like normal variables.
这篇关于将引用转换为C ++中的指针表示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文