Course Content
Introduction to C++
Simple Operators
The assignment operator (=
):
main.cpp
It works exactly the same with the string
data type:
main.cpp
The equality (==
) and inequality (!=
) operators are used to numerically compare 2 variables:
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:
main.cpp
Section 3.
Chapter 1