Object-Oriented Programming – Starting the Pong Game
In this chapter, there’s a little bit of theory, but the theory will give us the knowledge that we need to start using Object-Oriented Programming (OOP). OOP helps us organize our code into human-recognizable structures and handle complexity. We will not waste any time in putting that theory to good use as we will use it to code the next project, a Pong game. We will get to look behind the scenes at how we can create new C++ types that we can use as objects. We will achieve this by coding our first class. To get started, we will look at a simplified Pong game scenario so that we can learn about some class basics, and then we will start again and code a Pong game for real using the principles we have learned.
In this chapter, we will cover the following topics:
- Object-object programming: Discuss the staples of encapsulation, polymorphism, and inheritance, and why we would want to use OOP at all ...