By Mike Prestwood
Delphi versus C++: A side by side comparison between Delphi and C++.
Common statements such as if statements, loops, etc.
Notice in the more complete example that the semicolon for the begin..end block after end is not included. That tells the compiler something else is coming (the statement is not finished). Also note the semicolon is missing right before the final "else" statement.
Note: The following example uses floating point literals. In Delphi, to specify a fractional floating point literal between 1 and -1, you preceed the decimal with a 0; otherwise, you will get a compiler error (i.e. .1 + .1 does not work).
if (0.1 + 0.1 + 0.1) = 0.3 then ShowMessage('Correct')else ShowMessage('Not correct');
//Complete example:if x = true thenbegin
ShowMessage('x is true');
end
Else If y = 'Mike' Then
ShowMessage('hello mike')
Else
ShowMessage('last option');
Same as standard C.
//C++Builder example using the VCL ShowMessage.
int x;
x = 8;
if (x == 10) { ShowMessage("x is 10.");} else if (x < 10) { ShowMessage("x is less than 10.");} else { ShowMessage("x must be greater than 10.");}