Zitat von
sk.Silvia:
ok but ist the same also when i put
Delphi-Quellcode:
function TBinTree.FindMin(init:boolean):integer;
begin
if init then result:=self.Value;
//ShowMessage('val '+ValToStr+' res'+inttostr(result));
if value<result then
begin
result:=value;
end;
if not(left=nil) then result:=left.FindMin(false);
if not(right=nil) then result:=right.FindMin(false);
end;
value is always inicializes and result now too, but why the result changes besides on ShowMessage (again it gives the right value when i dont hide the showmessage dialog)
Yea, because at the first call result will be initialized. But every recursive call after that does not initialize the result variable. You call the method with false as init-parameter, which tells
not to initialize the variable. So once again: result is undefined
greetz
Mike