开发者

Visual C++/CLI (CLR) Null pointer

开发者 https://www.devze.com 2023-01-19 23:03 出处:网络
I wan\'t to implement the following code - the check if the pointer is null or not null. If the pointer points to object, then do sth with that object, if not - skip that code block.

I wan't to implement the following code - the check if the pointer is null or not null. If the pointer points to object, then do sth with that object, if not - skip that code block.

My code:

ref class EchoClient {
private:
    GameMatrix^ gameMatrix;
public:
    EchoClient(void);
    EchoClient(GameMatrix^);
    void do();
};

EchoClient::EchoClient(void)
{
    this->gameMatrix = NULL;
}

EchoCl开发者_StackOverflowient::EchoClient(gameMatrix)
{
    this->gameMatrix = gameMatrix;
}

void EchoClient::do() {
    if(this->gameMatrix != NULL)
    {
        this->gameMatrix->redrawMatrix();
    }
}

The error:

error C2446: '!=' : no conversion from 'int' to 'GameMatrix ^' k:\visual studio 2010\Projects\EchoClient3WS\EchoClient3WS\EchoClient.cpp    106

Any solutions ???


nullptr

0

精彩评论

暂无评论...
验证码 换一张
取 消