General N-ary Trees Implementation
However, this requires the allocation of dynamic memory in all cases. An alternate design is to use General N-ary Trees Implementations:
{` General N-ary Trees Implementation < typename object, int N> class Nary_tree{ private: object element; Nary_tree * children [std::max(N,2)|];//an array of N Children public: Nary_tree (object const &e ); element ( e) { for (int i = 0; i < N; ++i) { children[i] = 0; } }`}
n this case, we could create an N-ary tree as follows