Einzelnen Beitrag anzeigen

Benutzerbild von JasonDX
JasonDX
(CodeLib-Manager)

Registriert seit: 5. Aug 2004
Ort: München
1.062 Beiträge
 
#5

Re: Thats Insane - wrong memory setting by recursion???

  Alt 20. Apr 2006, 20:26
Zitat von sk.Silvia:
Delphi-Quellcode:
 function TBinTree.FindMin(init:boolean):integer;
      begin
      //ShowMessage('val '+ValToStr+' res'+inttostr(result));
      //result:=result;
      if value<result then
        begin
        result:=value;
        end;
      if init then result:=self.Value;
     
      if not(left=nil) then result:=left.FindMin(false);
      if not(right=nil) then result:=right.FindMin(false);
      end;

in prog -> ShowMessage(IntToStr(BinTree.MindMin(true)));
HOW CAN SHOWMESSAGE CHANGE THE RESULT OF A RECURSION????? AND WHY HAVE RESULT:=RESULT; THE SAME EFFECT??
First rule of local variables: Do always initialize them before usage You forgot that, and that might be the reason for the strange behaviour.

greetz
Mike
Mike
Passion is no replacement for reason
  Mit Zitat antworten Zitat