我想要实现以下代码 - 检查指针是否为null或非null。 如果指针指向对象,则对该对象执行某些操作,如果不是,则跳过该代码块。
我的代码:
ref class EchoClient {
private:
GameMatrix^ gameMatrix;
public:
EchoClient(void);
EchoClient(GameMatrix^);
void do();
};
EchoClient::EchoClient(void)
{
this->gameMatrix = NULL;
}
EchoClient::EchoClient(gameMatrix)
{
this->gameMatrix = gameMatrix;
}
void EchoClient::do() {
if(this->gameMatrix != NULL)
{
this->gameMatrix->redrawMatrix();
}
}
错误:
error C2446: '!=' : no conversion from 'int' to 'GameMatrix ^' k:\visual studio 2010\Projects\EchoClient3WS\EchoClient3WS\EchoClient.cpp 106
有解决方案吗?