有如下代码 class father{ public: virtual print(){ cout<<"In the father!"< };
class son0{ public: virtual print(int x){ cout<<"In the son"<<"input x is"< } }; class son_of_son{ public: virtual print(int x){ cout<<"In son of son!"<<"input x is"< } };
template bool element::insert(T input, element*p) //p point to the place to insert while not its parent! { if(!p){ p = new element(input); return true; } else false; }
element* p_tree; template bool find_pos_insert(T input, element* p_root) //p_root point the tree's sub-tree's root { bool ret; if (!p_root){ //p_tree = new element(input); ret = p_root->insert(input, p_root); return ret; } if(p_root->is_right(input) == true)//at right size of the present node if(!p_root->get_right()) p_root->insert(input, p_root->get_right()); else ret = find_pos_insert(input, p_root->get_right()); else if(p_root->is_left(input) == true)//at the left if(!p_root->get_left()) p_root->insert(input, p_root->get_left()); else ret = find_pos_insert(input, p_root->get_left()); else //equal root p_root->add_cnt(); return ret; } template bool right_browse(const element* p) { if(!p) return false;
}
template bool left_browse(const element* p) { if(!p) return false; } int main() { int input;