From the course: Complete Guide to C++ Programming Foundations

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Data members

Data members

- [Instructor] In this chapter, we will create a class from the ground up, adding elements in each exercise. The class we will create is the inventory in an action-adventure game involving quests and magic, where the player character collects items with different properties. During gameplay, the player may use, consume, or drop any of these items. The items may belong to different categories, such as food, weapons, magical items, and so on. Let's start with the class definition in line 9. You have already seen this syntax a few times in the course. It begins with the class keyword followed by the name of the class. We will call our class Inventory. This would be the declaration, so we could end this line with a semicolon, but we are also going to define the class here. So, I'll use curly brackets to define everything inside. Classes offer all the elements of object-oriented programming, and we should take advantage of those elements. So let me start by applying a feature of…

Contents