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,884 of 2,978   
   Heinrich Wolf to Robert Bralic   
   Re: Why Delphi and C++ ...??   
   31 Aug 05 21:02:34   
   
   From: invalid@invalid.invalid   
      
   "Robert Bralic"  schrieb im Newsbeitrag   
   news:df40a2$dlp$2@ss405.t-com.hr...   
   >   
   ...   
   > Dear,   
   >   
   > But this are a simple diferences in core these two languages, as   
   > Pascal and C (on procedural programming) are same...   
   > Also is for Delphi anc C++ (on object programming),   
   > I think that is posible to build template library also for Delphi...   
   >   
   >                                              Thanks, Robert !!   
   >   
   Up to now I have not known any newer than object-oriented pascal,   
   e.g. as it is used Delphi. Maybe somebody some time will design   
   oop++. I try to give an example of some future oop++,   
   in order to illustrate to those, who do not know C++,   
   what is meant by templates and operators.   
      
   unit main;   
      
   {$AppType Console}   
      
   type   
     tMyObject = class of tMyType;   
       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;   
      
   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