【发布时间】:2019-05-14 18:39:15
【问题描述】:
原来是这样
entity * Ptr[8] = { NULL, };
但是当我使用
通过引用将 Ptr 带到另一个函数时updateMap(&mapGrid, Ptr); //and
void updateMap(map * mapGridU, entity * entityPtr) //then
if (entityPtr[i] != NULL)// gives an error
它说没有运算符“!=”匹配实体和int的这些操作数
【问题讨论】:
-
entity * Ptr[8] = { NULL, };是什么意思? -
entity * entityPtr->entity ** entityPtr。 (我敢打赌,这不是您遇到的唯一错误。在 C++ 中,不要立即一个一个地解决错误,首先尝试从整体上解决它们) -
如果错误不在
updateMap(&mapGrid, Ptr);上,您的编译器需要更高的一致性标志。 -
(有点 OT:该代码看起来像 C,而不是(现代)C++。使用现代 C++,我敢打赌这个问题甚至不会首先存在(可调整大小的容器、
std::optional等。 ).) -
@appleapple 是抽象的父类
标签: c++ arrays class pointers null