在C ++中
这是我现在编写的功能 -
insertobjectnames(std::string clsname, std::string objname)
现在在上面的函数中,我必须调用另一个函数,该函数将与上面2相同的参数作为输入,但作为变量的地址。
第二个功能的声明如下 -
int BitmapHashMap::Insertnew(const std::string& key, std::string& value)
如何使用第一个函数中的clsname和objname参数来调用上面的第二个函数。第二个函数(在其自身内)从参数中提取'key'和'value'的值,然后使用它们。
答案 0 :(得分:2)
如果我理解你的问题,你想知道如何通过引用传递。第二个函数的参数已经通过引用传递。所以你的问题的答案很简单:
void insertobjectnames(std::string clsname, std::string objname) {
BitmapHashMap hashmap;
hashmap.Insertnew(clsname, objname);
}
当然这个玩具示例没有意义,但你没有告诉我们为什么你需要第一个功能。
答案 1 :(得分:0)
您只需使用clsname作为参数调用该函数,编译器将为您完成工作