Sorry for the indentation. Being used to IDE that automatically indent your code isn't a good habit, I guess.
I didn't thought about this case, since the xlength, ylength and profondeur I chose do not allow xlength or ylength to be equal to 0, and removing the "if (xlength==0||ylength==0)" didn't change anything.
But when I run it, I get correct values. If I place a printf("Done."); at the end of DivideTill(), it correctly reaches this part of the function (before crashing at the end), meaning the first part of the function went well (maybe I'm wrong assuming that ?).
Also, if I do something like that :
1 2 3 4
|
node root;
//Here I initialize root like this : x=0, y=0, xlength=ylength=20, profondeur=0
root.DivideTill(3);
root.DivideNode();
|
Then the issue dissapears, and main() returns 0, indicating that all went fine.
Also, about the memory leaks : I thought that a memory leak occured when I overwrite the only pointer that was pointing to some variable, meaning that the latter was "lost" and therefore undeletable.
Since I initialize left/rightchild as NULL in the constructor, and only call DivideNode once on a given node, is this still a problem ?