User-Agent: OSXnews 2.081
Xref: number1.nntp.dca.giganews.com comp.lang.c++:817435
Hi,
I searched online to see if this is valid or not (since my classes are
still very incomplete, I am unable to check it using compilation) but
did not find anything that answers my question.
I am trying to implement a tree as a doubly linked list.
So, I have a class Node,
class Node
{
// some stuff ctors, dtors, etc, BUT NO Default ctor;
Node &parent_node; // I want to avoid copying. ??
vector< list<Node>::iterator child_nodes; // ??
};
class Tree
{
//again ctors, dtors, and some other stuff;
list< Nodetreeofnodes;
};
So are the above declarations correct? I don't have a default ctor for
the Node class so am not sure if above would work.
One more question(if above WORKS):
can is do something like this:
list<Node &treeofnodes; //??
The advantage that I see in this is that I won't have to waste time
copying an instance of class Node when I insert it into the list..
If none of this is supposed to work, then I guess I have no other
option but to resort to pointers and use
class Node
{
// some stuff ctors, dtors, etc, BUT NO Default ctor;
Node *parent_node; //
vector< Node * child_nodes; //
};
class Tree
{
//again ctors, dtors, and some other stuff;
list< Node*treeofnodes;
};
thanks,
--a.