Home C C++ Java Python Perl PHP SQL JavaScript Linux Selenium QT Online Test

Home » Forum » x-Forum » Question

Family tree using templates-CppBuzz-Forum

Cant solve this hometask 

template<class T>
struct Node
	T* m_pPayload;
	Node* m_pParent;
	List<Node> m_Children;

template<class T>
struct Tree
	Node* m_pRoot;

typedef bool (*NodeComparator)(void* pValue, void* pPayload);

struct Person
	int id;
bool Comp(void* pValue, void* pPayload)
	Person* pVal = (Person*)pValue;
	Person* pPay = (Person*)pPayload;
	if (pVal->id == pPay->id)
		return true;
		return false;

template<class T>
void AppendChild(Node<T>* pParent, Node<T>* pNode);

template<class T>
Node<T>* FindNode(Node<T>* pParent, T* value, NodeComparator comparator);

Task: implement both functions and an example program that creates a family tree .

Posted by Mihrusha 2020-11-24 08:04:39

No Ans Posted

Please login to comment

Log In

Ask New Question