2

我想将一个子树从一个复制ptree到另一个。

源代码:

<abc>
<question>
--some-subtree--
</question>
</abc>


并生成:

<def>
<Version>1</Version>
<QueueQuestion>
--same-subtree-as-above--
</QueueQuestion>
</def>


做类似的事情:

ptree genReply(const ptree &pt)
{
ptree ret;
ret.put("def","");
ptree &subtree=ret.find("def")->second;
subtree.put("Version",1);
...
...
...
const Xml::ptree &q=pt.find("abc.Question")->second;
subtree.put_child("QueueQuestion",q);
...
...
return ret;
}

但是,我遇到了分段错误subtree.put_child("QueueQuestion",q);

有人知道吗?

4

0 回答 0