3 Smooth operator –exploring C++ operators
This chapter covers
- Getting to know the C++ operators
- The use of arithmetical operators
- Unraveling the logic behind logical operators and how to use them
- Using various comparisons using comparison operators
- Taking a firsthand look into the new C++ 20 three-way-comparison operator
- Assigning value using assignment operators
- Bitwise operators and their role.
In chapter 1 and 2 we helped you set a solid ground in understanding C++’s linguistic and syntactic logic, combined with an in depth understanding of variables and their role in memory allocation. In this chapter, we will move some steps forward, using everything you learned so far and adding to this solid base for learning some additional C++ language components and elements. You will learn all about operators, which can perform various operation in your code, and which you learned briefly about in the previous chapter. You will now get a better understanding of their role and usage with a lot of examples and code exercises. We also introduce the brand-new C++20 three-way comparison operator, also known as the spaceship operator, which can be used with some exciting capabilities within your code and brings a simple yet powerful method for comparison between objects.