0

在 C++ 中

这是我现在正在编码的功能-

   insertobjectnames(std::string clsname, std::string objname)

现在在上述函数中,我必须调用另一个函数,该函数将与上述 2 相同的参数作为输入,但作为变量的地址。

第二个函数的声明如下 -

   int BitmapHashMap::Insertnew(const std::string& key, std::string& value)

如何使用第一个函数中的 clsname 和 objname 参数来调用上面的第二个函数。第二个函数(在其内部)从参数中提取“key”和“value”的值,然后使用它们。

4

2 回答 2

2

如果我正确理解您的问题,您想知道如何通过引用传递。第二个函数的参数已经通过引用传递。所以你的问题的答案很简单:

void insertobjectnames(std::string clsname, std::string objname) {
    BitmapHashMap hashmap;
    hashmap.Insertnew(clsname, objname);
}

当然,这个玩具示例没有任何意义,但是您还没有告诉我们为什么需要第一个函数。

于 2013-10-30T19:11:07.663 回答
0

您只需以 clsname 作为参数调用函数,编译器将为您完成工作

于 2013-10-30T18:58:51.800 回答