You are on page 1of 14

Delphi C++Builder

,
C++ Object Pascal (, Delphi Borland),
Delphi C++ (++Builder
Borland). Object Pascal Delphi
"OP".

Op

++

Shortlnt

signed char

Smalllnt

16

short

Longlnt

32

int

Byte

unsigned char

Word

16

unsigned short

Integer

32

int

Cardinal

32

unsigned int

Boolean

true,false

bool

ByteBool

true,false 8
unsigned char

WordBool

true,false
16

unsigned short

LongBool

true,false
32

BOOL (WinAPI)

AnsiChar

char

WideChar

UNICODE
wchar_t

Char

char

AnsiString

AnsiString Delphi

AnsiString

String[n]

Delphi,
n= 1..255

SmallString

ShortString

Delphi,
255

SmallString

String

AnsiString Delphi

AnsiString

Single

32
float

Double

64
double

Extended

80
long double

Real

32
double

Pointer

32

void *

PChar
P AnsiChar

32 unsigned char *
ANSI 32
unsigned char *

Comp

64
Comp

OleV ariant

variant OLE

OleV ariant


, ++ , OP ,
.
C++
#define #elif #else #endif #error #if #ifdef #ifndef #include #line #pragma #printf #undef auto break
case catch char class const const_cast continue default delete do double dynamic_cast else enum
except extern false finally float for friend goto if inline int long mutable namespace new operator
private protected public register reinterpret_cast return short signed sizeof static static_cast struct
switch template this throw true try typedef typeid union unsigned using virtual void volatile while
xalloc new delete
OP
ABSOLUTE AND ARRA Y ASM ASSEMBLER BOOLEAN BYTE CASE CHAR COMP
CONST CONSTRUCTOR DESTRUCTOR DIV DO DOUBLE DOWNTO ELSE EXTENDED
EXTERNAL F ALSE FAR FILE FOR FORW ARD FUNCTION GOTO IF IMPLEMENTA TION
IN INLINE INTEGER INTERF ACE INTERRUPT LABEL LONGINT MOD NEAR NIL NOT
OBJECT OF OPERA TOR OR P ACKED PRIV A TE PROCEDURE PROGRAM REAL RECORD
REPEA T SET SHL SHORTINT SHR SINGLE STRING TEXT THEN TO TRUE TYPE UNIT
UNTIL USES V AR VIRTUAL WHILE WITH WORD XOR

C++
;
.

#include "foo.h" // ;
#define MAXNAMELENGTH 35 // ;
OP
;

C++
32 -
32 .

,
.
// ... ...
char sName[10];
int iCount, iLoop, iV alToReach;
double dMaxLoan, dTotal;
float fMaxRate = 123.875;
OP
63 -
63 .
"var"
.
var .
// ... ...
function PayBack_d(var dAmount: double): double ;
var
iCount, iLoop, iV alToReach: integer ;
dMaxLoan, dTotal, dMaxRate: double ;
begin
dMaxRate := 123.875;
...

C++
C++ . ,
('').
( )
. .
, C++
. ,
. ,
char*. :
char sName[26]; // 25 NULL
char psDemo[] = "Hello, there!";

char * psDemo = new char[26];


. strcat
() , strcmp , strcpy
, strstr , strlen
, strupr ,
sprintf
.
OP
Delphi ( 2 ),
255- , pascal-. $
string.
($+) string
. $- 255- pascal-.
Delphi . , ,
$, , 255,
(ShortString).
ShortString.
, Delphi 2.0,
.
:
.
, (heap). , Delphi32
.
, . , ,
Delphi 2.0 SetLength,
,
#0,
, null-terminated string.
,
StrPCopy, Delphi
Delphi . ,
(,
), .
, ,
, .
,

,
,
. , ,
(
), ,
. OpenString
var-, .

- (
). C ++ OP - .
++
" " - - [0], [1],
- [2], .. .
:
double Array[31];
:
for(int i = 30, j = 29; i > 0; i--,j--)
Array[i] = Array[j];
OP
1... . Delphi
" " ++. TList .

var ArrayS: array[1..31] of double;
i,j: integer;
begin
j := 30;
for i := 31 downto 2 do
begin
ArrayS[i] = ArrayS[j];
Dec(j); { j := j-1; }
end;
......

++
double dMatrix[50] [20];
OP
dMatrix: array[1..50, 1..20] of double;


C++
" " (==), (=)
int i,j;
if(i==j)//
.....
i=j;//
....
OP
"" (=), + (:=)
...
if dMaxRate = 15.75 then
begin ...
dMaxRate := 12.5;
...
end;
OP .
(=)

- , .
, C ++ OP . C ++ OP
.
++
const
const int iMax = 2000;
const double dMaxV alue = 1234.75;
++ #define
#define MAXA 1000

.
( ini double)
OP
, , "const"
, .
function PayBack_d(var dAmount: double): double;
const iMAX = 2000; dMAXV ALUE = 1234.75;
var iCount, iLoop, iV alToReach: integer;
dMaxLoan, dTotal, dMaxRate: double;
begin
dMaxRate := dMAXV ALUE;
{...}

, C ++, ""
, . OP ,
, . C ++,
, (
, ). OP , ,
( )
. C ++ ()
, . OP
() ,
, .
++

void Foo(double X);


int Foo2();

void Foo(double X)
{
int Y=X;
}
int Foo2()

{
return 0;
}
OP

"function" "procedure" .
function IntSinceLastAddDate_d(var dAvailCash: double): double;
procedure SetNewIntRate; { }
...
function LoanC.IntSinceLastAddDate_d(var dAvailCash: double): double;
var dSomething: double;
begin
...
result := dSomething; { "result"
!}
end;
procedure LoanC.SetNewIntRate;
begin
...
end;
C ++ OP
...
C++ ... double IntSinceLastAddDate_d(double dAvailCash);
OP ... function IntSinceLastAddDate_d(dAvailCash: double): double;
C++ ... double IntSinceLastAddDate_d(double &dAvailCash);
OP ... function IntSinceLastAddDate_d(var dAvailCash: double): double;
C++ ... double IntSinceLastAddDate_d(const double dAvailCash);
OP ... function IntSinceLastAddDate_d(const dAvailCash: double): double;
with ... do

, C ++ OP . , C ++ with ... do ...


, - OP. C ++
OP .
C ++, ,
...
poC.oStock.aoTradesLast130Days[0].lV ol = 0;
poC.oStock.aoTradesLast130Days[0].dHigh = 0;
poC.oStock.aoTradesLast130Days[0].dLow = 0;
poC.oStock.aoTradesLast130Days[0].dClose = 0;
OP , , ...
with poC.oStock.aoTradesLast130Days[0] do begin
lV ol := 0;
dHigh := 0;
dLow := 0;
dClose := 0;
end;
++.

. ... , OP ,
(OP) ++.

C++ 2 :

//

/*
, .
3 .
*/
OP ++ 3 . , Borland
Delphi Pascal C++.
++


//

(*
, .
3 .
*)
{
, OP
}
(if, else, switch...)
, .
.
1. if ... else
C++
if() //
{
...
}
else if()
{
...
}
else
{
...
}
OP

if then
begin
{ }
...
end
else if then
begin
....
end
else
begin
...
end; { "end" }
2. switch/case
C++
switch()
{
case iX: ... break;
case iY : ... break;
default: ...
}
OP
case of
{ "begin" }
iX:
begin
...

end; { "end";}
iY :
begin
...
end;
else { }
begin
...
end;
end;{ "end;" }
3. for
C++
for(iCount = 0; iCount
{
// , iCount++,
// 1
...
break; //
continue; //
...
}
OP
for iCount := 1 to 10 do
begin
... { for 1}
break; { }
continue; { }

...
end ;
"break" "continue" . C ++, break,
continue - - ;
OP . .
4. while
C++
while()
{
// ,

// false
...
break; //
continue; //
...
}
OP
while do
begin
{ ,
false }
...
break; { }
continue; { }
...
end;
5. do ... while

5) The do/repeat ... loop construct:


C++
do
{
// , .

...
break; //
continue; //
...
}while();
OP
repeat
{ e , .

begin ... end }
...
break; { }
continue; { }
...
until ;


http://www.realcoding.net/