C++ has five binary arithmetic operators, which take two operands and two unary arithmetic operators, which can take one operand. Five assignment operators can be created by combining these arithmetic operators with the equals sign to create 'assignment operators'.The arithmetic operators are +, -, *, /, %, with the operators + and - having unary versions which require only one operand. the assignment operators are +=, -+, *=, /+, and %=.
In Delphi the assignment operator is ' := ' while in C++ the assigment operator is simply ' = '. This would be the equivalency operator in Delphi, while in C++ the equivalency operator is ' == '. So in Delphi we would write ' if x = 16 then ' and in C++ this would be written as ' if (x==16) '. In Delphi we would write ' x := y ' which sets x equal to y, and in C++ we drop the colon the perform the same operation ... ' x = y'.
The other relational operators are similar in both languages. They are <, >, <=, >=, == and then in Delphi where we write ' <> ' (not equal) in C++ this becomes ' != '.
The logical operators in C++ representing a logical AND, OR, and NOT as applied to boolean operands are ' && ', ' || ', and ' ! '. There are also two logical assigment operators, ' &= ' and ' |= ' which perform and assign the results of a logical AND and a logical OR operation respectively. For example,
x &= 2;
This would be similar to writing ' x := x AND 2; '
One of the differences in a C++ logical test is that if the first test fails the second test may not be evaluated. To accomplish the same thing in Delphi requires nested if - then statements (there is also a compiler option to turn off 'full boolean evaluation').
For example the following statement would generate an error in Delphi in the second part of the statement if Delphi is doing full boolean evaluation and x is equal to zero, due to an attempted division by zero...
if (x = 0) or (100 div x < 10) then
In C++ this statement would not generate an error, since, if x was equal to zero the test would be considered a success and the other conditional statements need not be considered...
if (x==0 || 100 / x < 10)
Similarly in the above example a test to ensure that x is not zero would not cause a crash if the or relational operator was replaced by an 'and' relational operator.
In C++ you might see operators and operands combined in the following ways...
++x;
This is similar to writing inc(x) in Delphi, which means x := x + 1 (the difference being that the former generates more optimized code.
The increment operator can appear before or after the operand...
y = ++x;
y = x++;
In the first cause (pre-increment) x is incremented by one, and the result is then assigned to y. IN the second case, x is assigned to y and then x is incremented by one.
In Delphi we could write...
y := x; inc(x);
And in C++ this becomes...
y = x++;
An example of using an assignment operator in C++ ...
x /= z;
In this case two operands (x and z) are combined using an assignment operator. This statement could also be written as ' x = x / z; '
Assignment operators can also be evaluated from right to left in a statement resulting in strange looking calculations like the following.
x = y *= 10;
This is equivalent to following code...
y = y * 10; x = y;
When arithemetic operators are included multiple times in a single line the operators are evaluated from left to right if they have the same precedence, otherwise the operator with the highest precedence is evaluated first. One way to get around memorizing the precedence of operators is to enforce precedence using brackets, in which case the rule is that the inner most bracket is evaluated first, then so on until the outer most bracket is evaluated. For example, consider the following line of code without brackets.
x = y + z - q * 6 / t;
Both mulitiplication and division have a greater precedence than adding or substracting, and multiplication ' * ' and division ' / ' both have equal precedence so evaluating from left to right we get first q * 6 and then the result is divided by t. Then once again working from the left we get y + z evaluated and then the previous results of the multiplication and division are subtracted from this result and the solution is then assigned to the variable x. A change in precedence causes a change in results. One way to ensure that the results are what you want is to use brackets.
Let us suppose that first q should be subtracted from z and 6 should be divided by t and then these two results should multiplied together and then added to y. To override precedence and get the results we wanted we would need to use brackets...
x = y + ((z - q) * (6 / t));
The two inner brackets are evaluated first, then the multiplication in the outer bracket is evaluated, the result of these operations are then added to y and assigned to the variable x. This is considerably different than what would result if the rules of precedence were applied (indeed such a calculation would just about impossible to achieve without the brackets.
C++, like Delphi uses the ' dot operator ' to access fields of a record (on the stack) and a pointer operators to access variables on the heap.
In Delphi, assuming we have a record 'info' with a field 'age' we could access this using the dot operator if this was a static instance of the record (which would thus be on the stack, and not require a pointer).
x := info.age;
If info was dynamically created using a pointer we could access the fields using a pointer operator...
x := info^.age;
C++ also uses the dot operator for static records...
x = info.age;
To access a record on the heap (created with a pointer) the indirection operator in C++ looks like the following...
x = info->age;
Let us suppose that we have a pointer to an integer and wish to assign the value of the integer to a variable. In Delphi the indirection operator would appear as follows...
x := intptr^;
In this case ' intptr ' is a pointer to an integer delcared as follows...
var intptr : ^integer;
In C++ the variable is declared as follows...
int* intptr;
And then the indirection operation looks like the following...
x = *intptr;
This is pretty much the same as in Delphi.
A short code segment illustrating how this works in Delphi...
procedure TForm1.Button1Click(Sender: TObject);
var px : ^integer;
x : integer;
begin
new(px);
px^ := 12;
x := px^;
showmessage(IntToStr(x));
end;
For a C++ example of the same sort of thing follow the link to the C++ section at the bottom of the page and consult the section on C++ pointers...
C++ also has a bitwise not operator (the tilde ' ~ ')x |= ~0x02;
What is meant is that this number will be combined with the variable x using a bitwise NOT operation (each bit subjected to a NOT operation, in otherwords reversed from 0 to 1 or from 1 to 0 before the OR operation is applied) and the result then assigned back to x. This bitwise NOT operand is different than the logical NOT operand represented by the ' ! ' symbol, used in boolean expressions...
if (!something)
The scope resolution operator ( ' :: ') is discussed in the section on C++ Classes, and is the operand with the highest precedence.
The table below illustrates operator precendence in C++ ... As you can see along with the field operators (used in structures) brackets then have the next highest precedence, for the reasons explained above...All operators in each group have equal precedence with assignment operators of equal precedence being evaluated right to left and other operators left to right as described above...(Therefore a bracket to the left of dot operator would have precedence, which makes sense...)
:: scope resolution operator
. (the dot operator), -> (pointer), [ ] (square brackets), ( ) (round brackets), ++ and -- (post increment/decrement), and the various types cast operands
~ (tilde - bitwise not), ! (logical not), + and - (unary), ++ and -- (pre increment/decrement), , & (the address of operator), * (dereference a pointer), the new, the delete, and the size of functions
.* (the dot operator and the dereference operator), ->. (pointer operator and the dot operator)
* (as multiply), / , %
+, -
<< , >> (the assign out to and assign into operators, typically used in printing or file I/O)
<, >, <=, >= (the relational comparison operators)
==, != (equivalence test operators)
& (bitwise and)
^ (bitwise xor)
| (bitwise or)
&& (logical and)
|| (logical or)
=, +=, -+, *=, /+, %=, <<=, >>=, &=, |=, ^= (assignment operators)
? : (? is equivalent to 'then' and colon is equivalent to 'else' operator, with the lowest precedence so that everything is evaluated in the test statement before either the 'then' or 'else' code is executed, which also makes sense)
A Unified Field Theory
![]()
The Unified Field Theory
is also available as a zip file -> unified.zip
Introduction :The Pioneer Effect and the New Physics. A brief description of the new physics required to explain the 'Pioneer Effect', which is the constant deceleration of space craft as they fly through space.

