views:

36

answers:

1

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;
}

EchoClient::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 ???

+5  A: 

nullptr

leppie
Ahh, I just find out this myself. Looks like google don't wan't to suggest a qualified answer is first page (i found the solution only at 5-th results page)
ozzWANTED
@ozzWANTED: Third result when searching for 'CLR/C++ null pointer'
leppie
First result when searching for "C++/CLI null pointer". @ozz: you need to mark a good post like this as the answer. Having people look at this needlessly is wasting everybody's time.
Hans Passant
@Hans Passant: When I searched after I posted this, this was the first result too. Amazing how quickly Google indexes!
leppie