CPP新手 - 如何将值从字符串转换为引用(地址)变量
cpp newbie- how to convert values from string to ref (address of) variables
In C++
这是我现在正在编码的功能-
insertobjectnames(std::string clsname, std::string objname)
现在在上面的函数中,我必须调用另一个函数,该函数将与上述 2 相同的参数作为输入,但作为变量的地址。
第二个函数的声明如下-
int BitmapHashMap::Insertnew(const std::string& key, std::string& value)
如何使用第一个函数中的 clsname 和 objname 参数来调用上面的第二个函数。第二个函数(在自身内部)从参数中提取"键"和"值"的值,然后使用它们。
如果我理解你的问题正确,你想知道如何通过引用。第二个函数的参数已通过引用传递。因此,您的问题的答案很简单:
void insertobjectnames(std::string clsname, std::string objname) {
BitmapHashMap hashmap;
hashmap.Insertnew(clsname, objname);
}
当然,这个玩具示例本身没有意义,但您还没有告诉我们为什么需要第一个功能。
您只需使用 clsname 作为参数调用函数,编译器将为您完成这项工作
相关文章:
- 强制转换为引用类型
- 如何将 int 引用安全地转换为长引用?
- 右值引用转换后的地址更改
- C++将引用转换为指针?
- 如果可能的话,C++总是更喜欢右值引用转换运算符而不是常量左值引用吗?
- 将常量引用转换为智能指针而不复制
- 为什么不能将继承自(非模板)类 B 的实例化类模板 A 的引用转换为对 B 的引用?
- 通过 see 命令引用转换运算符
- 将项目转换为 qt5 并将未定义的引用转换为 'vtable for qt5 和 cmake
- 从 r 值引用转换为 l 值引用,为什么有效
- C++从右值引用转换为右值引用 a unique_ptr
- 将引用转换为 C++ 中的指针表示形式
- 如何正确地将引用转换为指针
- 正在将常量结构引用转换为非常量指针
- 将传递引用转换为传递返回
- 将.net引用转换为c++引用
- c++向量引用转换
- 如何将对int8_t的引用转换为对uint8_t的引用
- 如何在c++中将数字字符引用转换为Unicode
- 是否可以将对 std::list<int*> 的引用转换为对 std::list<const int*> 的引用?