Menu

Errors of value change and comment addition

Developer
Anonymous
2004-03-26
2004-03-26
  • Anonymous

    Anonymous - 2004-03-26

    1. I try to change value of the comment after his creation:

    TiXmlComment txcComment();
    txcComment.SetValue("Comment");

    error C2228: left of '.SetValue' must have class/struct/union type

    2. I try to add the comment in the document:

    TiXmlDocument txdDocument("test.xml");
    TiXmlComment txcComment();
    txdDocument.InsertEndChild(txcComment);

    error C2264: 'TiXmlNode::InsertEndChild' : cannot convert parameter 1 from 'TiXmlComment (void)' to 'const TiXmlNode &'

    If to add the TiXmlComment constructor with parameter

    (in tinyxml.h)
    TiXmlComment (const char * in_value);

    (in tinyxml.cpp)
    TiXmlComment::TiXmlComment (const char * _value) : TiXmlNode( TiXmlNode::COMMENT )
    {
    value = _value;
    }

    and to use a call

    TiXmlComment txcComment("Comment");
    txdDocument.InsertEndChild(txcComment);

    all becomes good.

    It really errors?

     
    • B Sizer

      B Sizer - 2004-03-26

      There are errors, but you've made them! :)

      TiXmlComment txcComment();  is a function prototype, declaring a function called txcComment that takes no parameters and returns a TiXmlComment. What you really wanted was:

      TiXmlComment txcComment;

      You don't need the new constructor.

       

Log in to post a comment.

MongoDB Logo MongoDB