Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

getting warning in Qt creator c++



  • Hi
    i have written code in c++ using qt creator IDE.
    i have decleared variable as

    TiXmlDocument *m_p_Doc;
    TiXmlElement *pElem, *pElem1;
    TiXmlHandle hRoot, hRootQuery;

    code compile correctly and working fine.
    but giving warning as
    warning: 'TiXmlElement* P2Response::pElem' [-Wreorder]
    TiXmlElement* pElem, *pElem1;

    so please suggest me


  • Moderators

    The compiler is just warning you that order of initialization will be different than what you requested.
    You need to initialize the variables in the constructor's initializer in the order they're declared in the class. E.g:

    class X
    {
        X()
            : a(0), b(0)  //< In the same order they're declared in the class, if you use b(0), a(0) it will generate the warning.
        {
        }
    
        int a;
        int b;
    }
    

Log in to reply