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 - C++ Tutorial
From the course: Complete Guide to C++ Programming Foundations
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
-
-
-
-
-
-
-
-
-
(Locked)
Overview of classes and objects5m 13s
-
(Locked)
Data members3m 1s
-
(Locked)
Function members8m 8s
-
(Locked)
Constructors and destructors5m 15s
-
(Locked)
Using classes2m 26s
-
(Locked)
Header and implementation files4m 23s
-
(Locked)
Working with several source files7m 8s
-
(Locked)
Operator overload4m 46s
-
(Locked)
Solution: Create a person class2m 22s
-
(Locked)
-
-
-