我试图用Visual 2010编译一些C++代码,但得到了以下错误:
错误C2664:'molder::Mold::set_piece_maker‘:无法将参数1从“piece_maker::Piece_Maker *const”转换为“piecemaker::Piece_Maker*”
该错误指的是管理两个类之间相互引用的两个镜像函数:
void Piece_Maker::set_mold(molder::Mold* value, void* origin) {
if (this->mold == value)
return;
this->mold = value;
this->mold->set_piece_maker(this, this); // This is the line with the error
}以及:
void Mold::set_piece_maker(piecemaker::Piece_Maker* value, void* origin) {
if (this->piece_maker == value)
return;
this->piece_maker = value;
this->piece_maker->set_mold(this, this);
}编译器会发生什么来引发这个错误呢?
发布于 2015-01-05 01:05:30
问题不是const,它是一个顶级的const,无论如何都被忽略了。请看两种垂直排列的类型:
piece_maker::Piece_Maker *const
piecemaker::Piece_Maker *https://stackoverflow.com/questions/27772129
复制相似问题