Visual C++/CLI (CLR) Null pointer

17,304

nullptr

Share:
17,304
ozzWANTED
Author by

ozzWANTED

My Experience: Web engineering (6-8 years): Php (8 years), Smarty, Symfony/Zend, HipHop HTML5, CSS 3.0, XML, WSDL, SOAP, ASP.NET, SilverLight Database engineering(2-8 years): MySQL (8 years), PostgreSQL (2 years) Software engineering (2-5 years): C# (4 years), Java SE, Nokia Belle (QT C++, QML), C++ (ISO, Visual), C, ASM Network & servers engineering: Ubuntu/CentOS, Varnish, Puppet, Cisco CCNA (including International CCNA Certification exam) Experience working as a team-leader (teams of 3-12 people) Specialities: Extreme programming, quick reaction, code quality

Updated on June 06, 2022

Comments

  • ozzWANTED
    ozzWANTED almost 2 years

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