Book Image

Learning C++ by creating games with UE4

By : William Sherif
Book Image

Learning C++ by creating games with UE4

By: William Sherif

Overview of this book

Table of Contents (19 chapters)
Learning C++ by Creating Games with UE4
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
2
Variables and Memory
Index

Chapter 6. Objects, Classes, and Inheritance

In the previous chapter, we discussed functions as a way to bundle up a bunch of lines of related code. We talked about how functions abstracted away implementation details and how the sqrt() function does not require you to understand how it works internally to use it to find roots. This was a good thing, primarily because it saved the programmer time and effort, while making the actual work of finding square roots easier. This principle of abstraction will come up again here when we discuss objects.

In a nutshell, objects tie together methods and their related data into a single structure. This structure is called a class. The main idea of using objects is to create a code representation for every thing inside your game. Every object represented in the code will have data and associated functions that operate on that data. So you'd have an object to represent your player instance and related functions that make the player jump(), shoot(), and...