c++tinyxml

no matching function for call to 'TiXmlElement::TiXmlElement(std::_cxx11::string&)


    for (int i = g, x=0; i < counter - 1 && x < 99; i++,x++){
std::string point = std::to_string(i);
std::string pointx = std::to_string(point_vec[i].x);
std::string pointy= std::to_string(point_vec[i].y);

TiXmlElement* P = new TiXmlElement( point );
TiXmlText* X = new TiXmlText(pointx);
doc.LinkEndChild(X);
TiXmlText* Y = new TiXmlText(pointy);
doc.LinkEndChild(Y);
doc.LinkEndChild(P);
}

Above is my example code which I am trying to work on right now, my issue is that it tells me the following:

"error: no matching function for call to 'TiXmlElement::TiXmlElement(std::_cxx11::string&)" this is using wxwidgets on c++, the idea behind using tinyxml is to be able to store the arrays and reuse them after.

Solvved this : I had to go into tinyxml.h and add this at the top : #define TIXML_USE_STL


Solution

  • There are two constructors for string/char type as below:

    TiXmlElement::TiXmlElement (const char * _value)
    

    or

    #ifdef TIXML_USE_STL
    TiXmlElement::TiXmlElement( const std::string& _value ) 
    

    So you have to define TIXML_USE_STL if you want to use std::string else use const char *

    Refer the tinyxml.cpp