course content

Course Content

Introduction to C++

Simple OperatorsSimple Operators

The assignment operator (=):

cpp

main.cpp

It works exactly the same with the string data type:

cpp

main.cpp

The equality (==) and inequality (!=) operators are used to numerically compare 2 variables:

cpp

main.cpp

Why 1 and 0? This is another method of using the bool type.
The expression var == 9 equals 1 (true) if var numerically equals the number 9.
The expression var == -9 equals 0 (false) if var is not numerically equal to the number 9.

The inequality operator is doing exactly the opposite:

cpp

main.cpp

Section 3.

Chapter 1