C++ Builder Tutorials

C++ Builder versus Delphi

A lot of classes, functions and structures are available in C++ Builder that work the same as their Delphi equivalents. But sometimes something has a different name, or the syntax there is different. A partial list of differences:

WhatDelphiC++ BuilderExamples
Array declaration arrayName[Size] of Type Type arrayName[Size] int age[4]
Array initialisation arrayName[Size] of Type=
 (values)
type arrayName[Size] =
 {values}
int age[4] = {10, 8, 21, 80}
Assignment x := y; x = y;  
Case case switch { case ... } switch (ch)
{
  case 'a': x = 1;
  case 'b': x = 2;
  case 'c': x = 3;
  default : x = 0;
}
Block of code begin ... end { ... }  
Comparison x = y x == y if (x == y) {...}
Compound
 operators
don't exist +=   -=   *=   /=   %=
<<=  >=  &=  ^=  |=
x += y;
Dec Dec(i) --i  
Exception catching try ... except ... try ... catch (...) ... try {
  n = StrToFloat(edInput1->Text);
}
catch (int) {
  ShowMessage("Invalid number");
}
Inc Inc(i) ++i  
Integer part of
 a variable
Trunc(x); int(x) n = int(x)
Method calling
 for a VCL object
ObjectName.Method ObjectName->Method() Panel1->Show();
Method declaration
 for a VCL object
Procedure
 ClassName.Method(...)
void __fastcall
 ClassName::Method(...)
void __fastcall
 TForm1::btnResultClick(...)
Procedure Procedure X(...) void X(...)
 procedures don't
 exist, use functions
 
Property OjectName.Property OjectName->Property Label1->Caption
Record declaration Record struct struct person
{
 string fullname;
 int age;
 float salary;
}
Variable declaration var VarName Type; Type VarName; float x;
string s1, s2;