Search code examples
c++boostheap-memory

Creating object in the heap


I'm using boost::ptree for parsing fils. The problem is that I can't create the object in the heap. All samples is only for stack.

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

I need this because the code is in a function and I have to return the ptree-object from it.

Errors:

‘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> >*’

Any ideas?


Solution

  • From what I can see, ptree does not seems to be recognized, are you sure the #include is alright or that ptree is realy what you meant?