GenTreeNode* root = new GenTreeNode (10); root->addChild(20); root->addChild(30); root->addChild(40); root->getChild(1)->addChild(50); root->getChild(1)->addChild(60); int nodeData = root->OperGet(GT_DATA); // Retrieves data of the root node (10) int childCount = root->OperGet(GT_CHILD_COUNT); // Retrieves child count of the root node (3) int childData = root->getChild(1)->OperGet(GT_DATA); // Retrieves data of the second child node (30)
GenTreeNodeThis example creates a general tree with string data type and retrieves the data and child count of the root node as well as the data of the first child node. In conclusion, GenTree OperGet method is used to retrieve data or properties of a particular node in a general tree. It is provided by the GenTree package library in C++.* root = new GenTreeNode ("A"); root->addChild("B"); root->addChild("C"); root->getChild(0)->addChild("D"); root->getChild(0)->addChild("E"); root->getChild(1)->addChild("F"); string nodeData = root->OperGet(GT_DATA); // Retrieves data of the root node ("A") int childCount = root->OperGet(GT_CHILD_COUNT); // Retrieves child count of the root node (2) string childData = root->getChild(0)->OperGet(GT_DATA); // Retrieves data of the first child node ("B")