AAAAAND THAT'S IT MY MATE! WE MADE IT!
So let's resume:
My Tree declares a List of Tree:
List<Tree<int> Nodes
nodes has a constructor like this:
Nodes(int N=0,Value2Assign=T())
NOW...BECAUSE OF T= Tree<int>
My Nodes constructor starts an endless loop, so the ONLY way to avoid this is to delete Value2Assign parameter so that no loop gets started.
the only problem is that if i create a list of n elems, this elements cannot have a value chosen by me. but that's not a problem.
for what concerns trees, for example, if i create Nodes(30), i want that each element of my list (a tree) sets his father to the object who contains the List.
I can make this in the constructor, making Setfather method private and setting, after their allocation, for each element the respective father:
1 2 3 4 5 6 7 8 9 10 11 12
|
Tree(Tree<T> *MyFather=NULL): MyFather(MyFather),LastPosUsed(POS_UNDEFINED),Value(T()){
int Counter;
if (GetNElems()>0){
for (Counter=0;Counter<GetNElems();Counter++){
Nodes[Counter].SetFather(*this);
}
}
}
|
BY THE WAY, FINALLY, WE CAN SAY THAT THIS THREAD HAS BEEN SOLVED! THANKS THANKS THANKS!
one negative note (if it has to be considered in this way) is that i had to use const_cast somewhere for "this" pointer and other things... but i think it would not be a problem because my object can't be modified by anything... am i wrong?
this may be the last posts my friend, so let's be happy! I owe you a beer!
GoodNight!