【发布时间】:2019-01-25 04:50:26
【问题描述】:
我在 linux 上有一个 c++11 项目,其中我使用了以下签名,它无法在 linux 上编译但在 windows 上编译
错误:
error: 'const' qualifiers cannot be applied to 'std::vector<long unsigned int>&'
error: 'const' qualifiers cannot be applied to 'std::map<long unsigned int, long unsigned int>&'
函数是
bool debugGlobalDs(std::vector<size_t> & const elementIds ,
std::map<long unsigned int, long unsigned int>& const mapElementIdToGlobalIndex)
{
....
return true
}
为什么我不能在这里使用 const 限定符?一旦我删除它,它也可以在 Linux 上正常编译。
【问题讨论】:
-
你不能有 const 引用。