home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 1,890 of 2,978   
   Heinrich Wolf to Heinrich Wolf   
   Re: Why Delphi and C++ ...??   
   01 Sep 05 07:28:38   
   
   From: invalid@invalid.invalid   
      
   "Heinrich Wolf"  schrieb im Newsbeitrag   
   news:3nmd6aF28sv2U1@individual.net...   
   >   
   > unit main;   
   >   
   > {$AppType Console}   
   >   
   > type   
   >  tMyObject = class of tMyType;   
   tMyObject = object of tMyType;   
   I should not mix apples with pears.   
   >    MyArray : Array of tMyType;   
   >    function MySum : tMyType;   
   >  end;   
   >   
   > function tMyObject.MySum;   
   >  var   
   >    i : Integer;   
   >    Sum : tMyType;   
   >    {   
   >      Sum is initialized to some useful default value by the compiler!   
   >      That is 0 for integers, and '' for strings.   
   >    }   
   >  begin   
   >    for i := 0 to Length(MyArray) - 1 do   
   >      Sum := Sum + MyArray[i];   
   >    MySum := Sum;   
   >  end;   
   >   
   > type   
   >  tMyIntObject = tMyObject of Integer;   
   >   
   > function Operator+(a, b : tMyIntObject) : Integer;   
   >  begin   
   >     Result := a.MySum + b.MySum;   
   >  end;   
   >   
   > var   
   >  MyIntObjectA,   
   >  MyIntObjectB : tMyIntObject;   
   >  MyStringObject : MyObject of String;   
   MyStringObject : tMyObject of String;   
   >   
   > begin   
   >  MyIntObjectA.MyArray.SetLength(2);   
   >  MyIntObjectA.MyArray[0] := 1;   
   >  MyIntObjectA.MyArray[1] := 2;   
   >  MyIntObjectB.MyArray.SetLength(2);   
   >  MyIntObjectB.MyArray[0] := 3;   
   >  MyIntObjectB.MyArray[1] := 4;   
   >  writeln(MyIntObjectA + MyIntObjectB); { writes '10' }   
   >  MyStringObject.MyArray.SetLength(2);   
   >  MyStringObject.MyArray[0] := 'My ';   
   >  MyStringObject.MyArray[1] := 'string';   
   >  writeln(MyStringObject.Sum); { writes 'My String' }   
   > end.   
   >   
   > Regards   
   > Heiner   
   >   
   > P.S.   
   > I prefer Delphi against C++, but C++ is much more powerful!   
   >   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca