我遇到了下面的代碼,儘管有別人的幫助,但我仍然無法理解它。 這段代碼應該實現一個通用樹。 Single_List和Single_Node類也可用於實現。實現常規樹
template <class Object>
class General_tree {
private:
Object element; // the stored in the node
Single_list< General_tree<Object> * > children;
// a linked list of pointers to general trees
public:
Object retrieve() {
return element;
}
// ...
};
有人能告訴我這個類的一個實例是由什麼組成的?
我認爲這將包括
[element value in node made by Single_Node] ----->
/ next pointer (part of Single_list class)
/
/children pointer to another such instance of General_Tree
V
然後,這些實例可以被組合成一個樹......我仍然習慣面向對象設計我想是這樣,請讓我知道如果這個推理解釋是正確的?
謝謝!
似乎沒有「下一個指針」。 – 2011-06-15 09:07:27
http://www.boost.org/doc/libs/1_41_0/doc/html/property_tree.html值得一看,如果你想在一些真正的(非訓練)代碼中做這樣的事情。 – 2011-06-15 09:10:49