|
|
(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
| |
− | |-
| |
− | | !=
| |
− | | <>
| |
− | | [[Not equal]]
| |
− | |-
| |
− | | &&
| |
− | | [[And]]
| |
− | |
| |
− | |-
| |
− | | <nowiki> || </nowiki>
| |
− | | [[Or]]
| |
− | |
| |
− | |-
| |
− | | ^
| |
− | | [[Xor]]
| |
− | |
| |
− | |-
| |
− | | >>
| |
− | | [[Shr]]
| |
− | | bit '''sh'''ift '''r'''ight
| |
− | |-
| |
− | | <<
| |
− | | [[Shl]]
| |
− | | bit '''sh'''ift '''l'''eft
| |
− | |-
| |
− | | ++
| |
− | | [[Inc]]
| |
− | |
| |
− | |-
| |
− | | --
| |
− | | [[Dec]]
| |
− | |
| |
− | |-
| |
− | | /*
| |
− | | { or (*
| |
− | | [[Comments|Comment]] start
| |
− | |-
| |
− | | */
| |
− | | } or *)
| |
− | | Comment end
| |
− | |-
| |
− | | //
| |
− | | //
| |
− | | End of line comment (only one line comment)
| |
− | |-
| |
− | | &
| |
− | | [[@]]
| |
− | | [[@|address operator]]
| |
− | |-
| |
− | | if()
| |
− | | [[If]] [[Then]]
| |
− | |
| |
− | |-
| |
− | | if() else
| |
− | | [[If]] [[Then]] [[Else]]
| |
− | |
| |
− | |-
| |
− | | while
| |
− | | [[While]] [[Do]]
| |
− | |
| |
− | |-
| |
− | | do while
| |
− | | [[Repeat]] [[Until]] [[Not]]
| |
− | |
| |
− | |-
| |
− | |-
| |
− | | do while !
| |
− | | [[Repeat]] [[Until]]
| |
− | |
| |
− | |-
| |
− | | for ++
| |
− | | [[For]] [[To]] [[Do]]
| |
− | |
| |
− | |-
| |
− | | for --
| |
− | | [[For]] [[Downto]] [[Do]]
| |
− | |
| |
− | |-
| |
− | | switch case break
| |
− | | [[Case]] [[Of]] [[End]]
| |
− | |
| |
− | |-
| |
− | | switch case break default
| |
− | | [[Case]] [[Of]] [[Else]] [[End]]
| |
− | |
| |
− | |-
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable"
| |
− | ! C++ type !! [[Pascal]] [[Data_type|type]] !! Size (bits) !! Range !!
| |
− | |-
| |
− | | char
| |
− | | [[Char]]
| |
− | | 8-bit
| |
− | |
| |
− | | [[ASCII]]
| |
− | |-
| |
− | | signed char
| |
− | | [[Shortint]]
| |
− | | 8-bit
| |
− | | -128 .. 127
| |
− | |
| |
− | |-
| |
− | | unsigned char
| |
− | | [[Byte]]
| |
− | | 8-bit
| |
− | | 0 .. 255
| |
− | |
| |
− | |-
| |
− | | char*
| |
− | | [[PChar]]
| |
− | | (32-bit)
| |
− | |
| |
− | | Pointer to a null-terminated string
| |
− | |-
| |
− | | short int
| |
− | | [[SmallInt]]
| |
− | | 16-bit
| |
− | | -32768 .. 32767
| |
− | |
| |
− | |-
| |
− | | unsigned short int
| |
− | | [[Word]]
| |
− | | 16-bit
| |
− | | 0 .. 65535
| |
− | |
| |
− | |-
| |
− | | int
| |
− | | [[Integer]]
| |
− | | (16-bit or) 32-bit
| |
− | | -2147483648..2147483647
| |
− | | Generic integer types
| |
− | |-
| |
− | | unsigned int
| |
− | | [[Cardinal]]
| |
− | | (16-bit or) 32-bit
| |
− | | 0 .. 4294967295
| |
− | | Generic integer types
| |
− | |-
| |
− | | long int
| |
− | | [[LongInt]]
| |
− | | 32-bit
| |
− | | -2147483648..2147483647
| |
− | |
| |
− | |-
| |
− | | unsigned long int
| |
− | | [[LongWord]]
| |
− | | 32-bit
| |
− | | 0 .. 4294967295
| |
− | |
| |
− | |-
| |
− | | float
| |
− | | [[Single]]
| |
− | | 32-bit
| |
− | | 1.5E-45 .. 3.4E+38
| |
− | |
| |
− | |-
| |
− | | double
| |
− | | [[Double]]
| |
− | | 64-bit
| |
− | | 5.0E-324 .. 1.7E+308
| |
− | |
| |
− | | |
− | |-
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable"
| |
− | ! C++ type !! [[Pascal]]
| |
− | !
| |
− | |-
| |
− | | class { }
| |
− | | [[Class]] [[End]]
| |
− | |
| |
− | |-
| |
− | | class: { }
| |
− | | [[Class]]( ) [[End]]
| |
− | |
| |
− | |-
| |
− | | template <class T> class { }
| |
− | | [[Generic]] = [[Class]]<T> [[End]]
| |
− | |
| |
− | |-
| |
− | | struct { }
| |
− | | [[Record]] [[End]]
| |
− | |
| |
− | |-
| |
− | | struct { }
| |
− | | [[Object]] [[End]]
| |
− | | If you want methods
| |
− | |-
| |
− | | union { }
| |
− | | [[Record]] [[Case]] [[Of]] [[End]]
| |
− | | [[Case#Variant Record|Variant Record]]
| |
− | |-
| |
− | |}
| |