• Advertisement
Sign in to follow this  

Untitled

This topic is 4732 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[source +"cpp"]template <class dataType>
class LinkedList
{
    template <class dataType>
    class listNode
    {
    public:
        
        listNode<dataType>* next;       
    };
 ¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£};

template <class dataType>
class GeneralTree

{    dataType m_data;
   LinkedList<GeneralTree<dataType>*> m_children;
}



Õâ¸öLinkedList<GeneralTree<dataType>*> m_children; what does this sentence mean??

Share this post


Link to post
Share on other sites
Advertisement
This means the general tree class stores internally a list of its children.
Its children are represented by a linked list of pointers to general tree classes.
The name GeneralTree is here misleading and the name of the templated class adds to confusion. The GeneralTree class here represents a leaf of the tree and stores internally a linked list of pointers to the children leaves of the tree.

If you declare an Int tree (or an Ent ;) ), you have:

//tree declaration
GeneralTree<Int> MyTree
//internal children representation
LinkedList< GeneralTree<int>* > m_children;



Hope that clarifies.
Ghostly yours,
Red.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement