Chapter     3

Creating Calculators with Operators

C++ provides operators that allow you to express all sorts of mathematical formulae in computer programs. You have access to operators that allow us to carry out algebra, compare values, and even manipulate the individual bit pattern of a variable’s value directly. This chapter is going to cover these C++ operators and end by having you create a simple command line calculator.

The Assignment Operator

The first operator we are going to look at is the assignment operator. We have already been using the assignment operator in the previous chapters as it is the operator that allows us to assign a value to a variable. This operator uses the = symbol:

int number1 = 1;

As you can see we have assigned ...

Get Learn C++ for Game Development now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.