【发布时间】:2021-03-12 06:51:21
【问题描述】:
我看到一个代码正是使用这个,但是那个代码可以工作而我的不行,知道为什么吗?
PD:我正在尝试实现这个commit。看看代码是不是一模一样
for(const auto& tx : block.vtx)
if (txHash == tx->GetHash()) {
txNew = tx;
foundAtOut = *pindex;
return true;
}
main.cpp:2471:25: error: no match for ‘operator=’ (operand types are ‘CTransactionRef’ {aka ‘std::shared_ptr<const CTransaction>’} and ‘const CTransaction’)
txNew = tx;
【问题讨论】:
-
shared_ptr::operator=期望分配一个原始指针、另一个shared_ptr或unique_ptr。txNew是shared_ptr,但tx与shared_ptr不兼容。
标签: c++ shared-ptr