sách gpt4 ăn đã đi

c++ - 没有来自 'const std::__1::basic_string to ' std::__1::basic_string *' 的可行转换

In lại 作者:搜寻专家 更新时间:2023-10-31 01:35:30 25 4
mua khóa gpt4 giày nike

我目前正在为一个类项目工作,其中我必须在 C++ 中实现布谷鸟哈希。问题是,C++ 和我从来都不是 friend ,而且我认为我们永远不会...

具体的问题是,我无法在已经存在的对象上设置指针。当我这样做时,我得到了编译错误:

没有从 'const std::__1::basic_string 到 'std::__1::basic_string' 的可行转换*

两条语句都出现错误:

E * activeE = e;
E * tempE = v1[pos];

v1 是一个 E 对象数组。

我认为这个错误是由于我对C++基本概念的普遍误解造成的。我认为对你们来说这个问题是个笑话,但无论如何我希望你们能帮助我。

template 
void Hashing::add_(const E& e) {

size_t pos = h1(e);
size_t i = 0;

E * activeE = e;
E * tempE = v1[pos];

while (i < nmax) {
if (tempE == NULL) {
v1[pos] = activeE;
phá vỡ;
}

v1[pos] = activeE;
activeE = tempE;

pos = h2(activeE);
tempE = v2[pos];

if (tempE == NULL) {
v2[pos] = activeE;
phá vỡ;
}

v2[pos] = activeE;
activeE = tempE;

pos = h1(activeE);
tempE = v1[pos];
}

}

câu trả lời hay nhất

你有 const E& ehiện hữuHashing::add_方法,但在其中分配 định hướng E 的指针- 实际上这会产生不同的错误:

 'const std::__1::basic_string to 'std::__1::basic_string*"
^

所以修复,因为这是改变:

 E * activeE = e;
E * tempE = v1[pos];

đến

 const E * activeE = &e;
const E * tempE = &v1[pos];

关于c++ - 没有来自 'const std::__1::basic_string to ' std::__1::basic_string *' 的可行转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37271245/

25 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress