Error in TinyXml++ tutorial

232 Views Asked by At


trying to compile the TinyXml++ tutorial with CodeBlocks (16.01) and with VS2013 I get the same error at following line:

ticpp::Element* pElem = doc.FirstChildElement()->NextSibling();

CodeBlocks error:

invalid conversion from 'ticpp::Node*' to 'ticpp::Element*' [-fpermissive]

VS2013 error:

cannot convert from 'ticpp::Node *' to 'ticpp::Element *'

Any idea?

2

There are 2 best solutions below

0
pdereg On

In case you still want to compile it, regardless of whether there is an error in the tutorial, you can use the auto keyword for variable declaration.

For example:

auto pElem = doc.FirstChildElement()->NextSibling();

This way, the compiler will deduce the variable type at compile time.

0
Chen On

The return type of NextSibling() is Node*. If you want Element* as return type, you can use NextSiblingElement() instead.