Difference between revisions of "Pascal for C++ users"

From Lazarus wiki
Jump to navigationJump to search
(Redirected page to Pascal for C users)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
Note: Logical operators (AND/OR/XOR etc) are logical or boolean depending on the type of the arguments (boolean or integer). Since Pascal had a separate boolean type from the start, boolean operators on integers were not necessary, and are always logical.
+
#REDIRECT [[Pascal for C users]]
 
 
{| class="wikitable"
 
! C++ !! [[Pascal]] !!
 
|-
 
|   {  
 
|   [[Begin]]  
 
|  
 
|-
 
|   }  
 
|   [[End]]
 
|  
 
|-
 
|   =  
 
|   :=
 
|   [[Becomes]]  
 
|-
 
|   ==  
 
|   =
 
|   [[Equal]]
 
|-
 
|   /  
 
|   /
 
|   [[Slash|Float Division]] (Integer: [[Div|div]])  
 
|-
 
|   %  
 
|   [[Mod]]
 
|   '''Mod'''ulo operation
 
|-
 
|   !  
 
|   [[Not]]
 
|   Logical and boolean depending on arguments
 
|-
 
|   !=  
 
| &nbsp; <>
 
| &nbsp; [[Not equal]]  &nbsp;
 
|-
 
| &nbsp; && &nbsp;
 
| &nbsp; [[And]]
 
| &nbsp;
 
|-
 
| &nbsp; <nowiki> || </nowiki> &nbsp;
 
| &nbsp; [[Or]]
 
| &nbsp;
 
|-
 
| &nbsp; ^ &nbsp;
 
| &nbsp; [[Xor]]
 
| &nbsp;
 
|-
 
| &nbsp; >> &nbsp;
 
| &nbsp; [[Shr]]
 
| &nbsp; bit '''sh'''ift '''r'''ight &nbsp;
 
|-
 
| &nbsp; << &nbsp;
 
| &nbsp; [[Shl]]
 
| &nbsp; bit '''sh'''ift '''l'''eft &nbsp;
 
|-
 
| &nbsp; ++ &nbsp;
 
| &nbsp; [[Inc]]
 
| &nbsp;
 
|-
 
| &nbsp; -- &nbsp;
 
| &nbsp; [[Dec]]
 
| &nbsp;
 
|-
 
| &nbsp; /* &nbsp;
 
| &nbsp; { or (*
 
| &nbsp; [[Comments|Comment]] start
 
|-
 
| &nbsp; */ &nbsp;
 
| &nbsp; } or *)
 
| &nbsp; Comment end
 
|-
 
| &nbsp; // &nbsp;
 
| &nbsp; //
 
| &nbsp; End of line comment (only one line comment) &nbsp;
 
|-
 
| &nbsp; & &nbsp;
 
| &nbsp; [[@]]
 
| &nbsp; [[@|address operator]]
 
|-
 
| &nbsp; if() &nbsp;
 
| &nbsp; [[If]] [[Then]]
 
| &nbsp;
 
|-
 
| &nbsp; if() else &nbsp;
 
| &nbsp; [[If]] [[Then]] [[Else]]
 
| &nbsp;
 
|-
 
| &nbsp; while &nbsp;
 
| &nbsp; [[While]] [[Do]]
 
| &nbsp;
 
|-
 
| &nbsp; do while &nbsp;
 
| &nbsp; [[Repeat]] [[Until]] [[Not]]&nbsp;
 
| &nbsp;
 
|-
 
|-
 
| &nbsp; do while ! &nbsp;
 
| &nbsp; [[Repeat]] [[Until]] &nbsp;
 
| &nbsp;
 
|-
 
| &nbsp; for ++ &nbsp;
 
| &nbsp; [[For]] [[To]] [[Do]]
 
| &nbsp;
 
|-
 
| &nbsp; for -- &nbsp;
 
| &nbsp; [[For]] [[Downto]] [[Do]] &nbsp;
 
| &nbsp;
 
|-
 
| &nbsp; switch case break &nbsp;
 
| &nbsp; [[Case]] [[Of]] [[End]]
 
| &nbsp;
 
|-
 
| &nbsp; switch case break default &nbsp;
 
| &nbsp; [[Case]] [[Of]] [[Else]] [[End]] &nbsp;
 
| &nbsp;
 
|-
 
|}
 
 
 
 
 
{| class="wikitable"
 
! C++ type !! [[Pascal]] [[Data_type|type]] !! Size (bits) !! Range !!
 
|-
 
| &nbsp; char &nbsp;
 
| &nbsp; [[Char]] &nbsp;
 
| &nbsp; 8-bit
 
| &nbsp;
 
| &nbsp; [[ASCII]]
 
|-
 
| &nbsp; signed char &nbsp;
 
| &nbsp; [[Shortint]]
 
| &nbsp; 8-bit
 
| &nbsp; -128 .. 127
 
| &nbsp;
 
|-
 
| &nbsp; unsigned char &nbsp;
 
| &nbsp; [[Byte]]
 
| &nbsp; 8-bit
 
| &nbsp; 0 .. 255
 
| &nbsp;
 
|-
 
| &nbsp; char* &nbsp;
 
| &nbsp; [[PChar]]
 
| &nbsp; (32-bit)
 
|
 
| &nbsp; Pointer to a null-terminated string &nbsp;
 
|-
 
| &nbsp; short int &nbsp;
 
| &nbsp; [[SmallInt]]
 
| &nbsp; 16-bit
 
| &nbsp; -32768 .. 32767 &nbsp;
 
|
 
|-
 
| &nbsp; unsigned short int &nbsp;
 
| &nbsp; [[Word]]
 
| &nbsp; 16-bit
 
| &nbsp; 0 .. 65535 &nbsp;
 
|
 
|-
 
| &nbsp; int &nbsp;
 
| &nbsp; [[Integer]]
 
| &nbsp; (16-bit or) 32-bit  &nbsp;
 
| &nbsp; -2147483648..2147483647 &nbsp;
 
| &nbsp; Generic integer types &nbsp;
 
|-
 
| &nbsp; unsigned int &nbsp;
 
| &nbsp; [[Cardinal]]
 
| &nbsp; (16-bit or) 32-bit  &nbsp;
 
| &nbsp; 0 .. 4294967295 &nbsp;
 
| &nbsp; Generic integer types &nbsp;
 
|-
 
| &nbsp; long int &nbsp;
 
| &nbsp; [[LongInt]]
 
| &nbsp; 32-bit
 
| &nbsp; -2147483648..2147483647 &nbsp;
 
| &nbsp; 
 
|-
 
| &nbsp; unsigned long int &nbsp;
 
| &nbsp; [[LongWord]]
 
| &nbsp; 32-bit
 
| &nbsp; 0 .. 4294967295
 
| &nbsp; 
 
|-
 
| &nbsp; float &nbsp;
 
| &nbsp; [[Single]]
 
| &nbsp; 32-bit
 
| &nbsp; 1.5E-45 .. 3.4E+38 &nbsp;
 
|
 
|-
 
| &nbsp; double &nbsp;
 
| &nbsp; [[Double]]
 
| &nbsp; 64-bit
 
| &nbsp; 5.0E-324 .. 1.7E+308 &nbsp;
 
|
 
 
 
|-
 
|}
 
 
 
 
 
{| class="wikitable"
 
! C++ type !! [[Pascal]]
 
!
 
|-
 
| &nbsp; class { } &nbsp;
 
| &nbsp; [[Class]] [[End]] &nbsp;
 
| &nbsp;
 
|-
 
| &nbsp; class: { } &nbsp;
 
| &nbsp; [[Class]]( ) [[End]] &nbsp;
 
| &nbsp;
 
|-
 
| &nbsp; template <class T> class { } &nbsp;
 
| &nbsp; [[Generic]] = [[Class]]<T> [[End]] &nbsp;
 
| &nbsp;
 
|-
 
| &nbsp; struct { } &nbsp;
 
| &nbsp; [[Record]] [[End]] &nbsp;
 
| &nbsp;
 
|-
 
| &nbsp; struct { } &nbsp;
 
| &nbsp; [[Object]] [[End]] &nbsp;
 
| &nbsp; If you want methods
 
|-
 
| &nbsp; union { } &nbsp;
 
| &nbsp; [[Record]] [[Case]] [[Of]] [[End]] &nbsp;
 
| &nbsp; [[Case#Variant Record|Variant Record]] &nbsp;
 
|-
 
|}
 

Latest revision as of 21:38, 16 July 2014

Redirect to: