10 OOPs, we did it again – Object Oriented Programming and C++

 

This chapter covers

  • Understanding the concept of Object Oriented Programming (OOP)
  • Learning how to create classes, objects, constructors, and destructors
  • Understanding the concepts of abstraction and encapsulation
  • Practicing inheritance, and polymorphism
  • Practicing function overloading and operator overloading in an OOP environment

In this chapter, you will learn about the fundamental concepts and principles behind OOP (Object Oriented Programming). OOP is a powerful programming paradigm, that revolutionized the way we design, organize, and build software systems, allowing us to create a collection of data (objects) and functionalities (functions), organized in a special structure called Class. With OOPs structured approach to software development, we can write modular, reusable, and maintainable code. We can manage complexity, enhance code readability, and allow code reusability by organizing code into classes and objects.

OOP is a huge concept on its own, and whole books were written on OOP alone. In this chapter, we offer a glimpse into the core principles of OOP and explore its key concepts, such as classes, objects, abstraction, inheritance, polymorphism, and encapsulation. We will learn how to model real-world entities, abstract their behavior, and represent them as software objects.

10.1 Get Classy: introduction to Object Oriented Programming

10.2 Travel first class – The concept of classes

10.2.1 It’s classic: how to define a class

10.2.2 I object: Creating objects in our class

10.3 Constructors and Destructors

10.3.1 The constructor – an important OOP actor

10.3.2 The destructor factor

10.4 The four pillars of OOP

10.5 Abstraction: separates the ‘what’ from the ‘how’

10.6 Taming the Chaos: The Power of Encapsulation

10.6.1 Who needs ‘this’? The ‘this’ keyword:

10.6.2 The getter and setter functions

10.6.3 You’ve got a friend in me: friend function and friend class

10.7 Inheritance: The Gift That Keeps on Giving (Code, That Is)

10.7.1 Like Father, Like Child: The power of inherited properties

10.7.2 Back to base: Base class initialization

10.7.3 Make your code wealthy: multiple inheritances in action

10.8 Polymorphism

10.8.1 Abstract classes and pure virtual functions

10.8.2 The OOPs and Wows of OOP

10.9 Summary