/* * tree.cpp * * Created on: 5.01.2015 г. * Author: trifon */ #include #include "linked_list.cpp" using namespace std; struct Employee { char name[100]; Employee* boss; }; template class Tree { private: T root; // !!! Tree tree; LinkedList > subtrees; public: typedef LinkedListIterator > I; Tree(T const& _root = T()) : root(_root) {} T& operator*() { return root; } T const& operator*() const { return root; } I children() const { return subtrees.begin(); } Tree& addChild(Tree const& child) { subtrees.insertEnd(child); return *this; } }; template ostream& operator<<(ostream& os, Tree const& t) { os << '('; os << *t; for(typename Tree::I it = t.children(); it; ++it) os << *it; return os << ')'; }