////main.cpp
#include <windows.h>
#include "appTreeNode.h"
int APIENTRY WinMain(HINSTANCE hInst,HINSTANCE hPrev,LPSTR lp,int nShowCmd)
{
appTreeNode<int> *AlarmTree; //creo el arbol de ints
AlarmTree->AddSon(0); //le añado un 0
return 0;
}
////// appTreeNode.h
template <class T>
class appTreeNode
{
protected:
T Data;
appTreeNode<T> *Parent;
appTreeNode<T> *Son;
appTreeNode<T> *Brother;
public:
appTreeNode<T>(T TData) : Parent(NULL),
Son(NULL),
Brother(NULL)
{this->Data=TData;}
~appTreeNode<T> ();
void AddSon(T Son);
};
///////// appTreeNode.cpp
//------------------------------------------------------------------------------- Destructor
template <typename T>
appTreeNode<T>::~appTreeNode<T> ()
{
///TO DO///
};
//------------------------------------------------------------------------------- AddSon
template <typename T>
void AddSon (T Son)
{
appTreeNode<T> *Tmp;
if (this->Son==NULL)
{
this->Son=new appTreeNode<T>(Son);
this->Son->SetParent(this);
}
else
{
Tmp=this->Son;
while (Tmp->Brother!=NULL)
Tmp=Tmp->Brother;
Tmp->Brother=new appTreeNode<T>(Son);
Tmp->SetParent(this);
}
};