A
Amit Bhatia
Hi,
I have posted this post also for the thread "vector of lists" but since
it is about something else (though related) I am posting it again under
new thread.
I want to make a tree of nodes as follows, but am not sure now if it
will work:
In node.h
class Node
{
// some stuff ctors, dtors, etc;
//Default ctor;
Node &parent_node; // Could use pointer here but want to avoid it if
possible. vector< Node & > child_nodes; //Could use pointer here but
want to avoid it if possible.};
In tree.h
class Tree
{
//again ctors, dtors, and some other stuff;
list< Node &> treeofnodes;
};
I don't want to create duplicate copies of nodes, and want everything to
point correctly to elements in the global list treeofnodes.
I am not sure though if above can be done, as there needs to be some
kind of default ctor required and I am using references also..
thanks,
--a.
--
I have posted this post also for the thread "vector of lists" but since
it is about something else (though related) I am posting it again under
new thread.
I want to make a tree of nodes as follows, but am not sure now if it
will work:
In node.h
class Node
{
// some stuff ctors, dtors, etc;
//Default ctor;
Node &parent_node; // Could use pointer here but want to avoid it if
possible. vector< Node & > child_nodes; //Could use pointer here but
want to avoid it if possible.};
In tree.h
class Tree
{
//again ctors, dtors, and some other stuff;
list< Node &> treeofnodes;
};
I don't want to create duplicate copies of nodes, and want everything to
point correctly to elements in the global list treeofnodes.
I am not sure though if above can be done, as there needs to be some
kind of default ctor required and I am using references also..
thanks,
--a.
--