i want to create a tree-like structure, made up of connected nodes. each node has a mother and a father node, and possibly everal children. all nodes should be allocated dynamically. the problem then becomes the first "root" node.
my solution (which doesn work): typedef std::shared_ptr<Node> NodeRef;
in the PRIVATE constructor, i check if a NodeRef m_root exists, if not then create one via: m_root = NodeRef(new Node(args));
that doesnt work, it has something to do with memory (<xmemory> new bla bla i dont really understand)
to create a new node, i want to call a static member "Create" which creates a new node, and makes sure that it is connected to the tree. in case one parent doesnt exist, it will be "root" by default.
any suggestions ?
do i have to make a "Initialize()" + "CleanUp()" call before / after using the node tree ?
by the way:
if i create a shared_ptr<Node>(&m_root), and m_root is created as global variable in .cpp file, the program creashed at the end (maybe because "delete" is called on the address ?)