An introduction to OOP and the C++ object model
When writing a book about C++, you just have to talk about OOP because a) C++ is an object-oriented language, and b) OOP is at the heart of C++, which is also known by its original name – “C with classes.” OOP is one of the many paradigms that exist in the programming world. Its main purpose is to make the life of a programmer easier by allowing them to represent everything that exists in the real world with the help of objects.
Understanding objects
The majority of the time, we work with a set of data grouped together with a name, thus creating an abstraction. When viewed separately, variables such as is_military
, speed
, and seats
don’t make much sense. We see the information stored in the variables differently when we group them together under the term spaceship
. The multiple variables that are packed together are now referred to as one object. In order to accomplish this, we employ abstraction, which...