【问题标题】:Creating object in the heap在堆中创建对象
【发布时间】:2010-08-29 05:23:21
【问题描述】:

我正在使用 boost::ptree 来解析文件。问题是我无法在堆中创建对象。所有样本仅用于堆栈。

#include <boost/property_tree/ptree.hpp>
ptree *tree_handle;
read_info("path", tree_handle);

我需要这个,因为代码在一个函数中,我必须从中返回 ptree 对象。

错误:

‘boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> >*’ is not a class, struct, or union type

request for member ‘swap’ in ‘pt’, which is of non-class type ‘boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> >*’

有什么想法吗?

【问题讨论】:

标签: c++ boost heap-memory


【解决方案1】:

据我所知,ptree 似乎没有被识别,你确定 #include 没问题还是 ptree 真的是你的意思?

【讨论】:

  • 是的,当我尝试将其放入堆栈时 ptree tree_handle 一切正常。
猜你喜欢
  • 1970-01-01
  • 2016-10-23
  • 1970-01-01
  • 2010-12-08
  • 2016-12-15
  • 2013-10-26
  • 2012-02-14
  • 2010-09-05
  • 2023-03-16
相关资源
最近更新 更多