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.
Overview of classes and objects - C++ Tutorial
From the course: Complete Guide to C++ Programming Foundations
Overview of classes and objects
- [Instructor] We are now ready to write our own classes. So here are some important details of C++ classes and objects you need to keep in mind before we start writing code. In C++, a class is essentially a blueprint for creating objects. Think of a class as a design template that defines the structure and behavior of something in your program. Objects are the specific instances of the classes created at runtime. For example, if we had a class for a potion, each portion we create would be an object of that class. Classes are made up of members, which include data members and function members. Data members are variables that hold the object's state, like a potion strength or duration. Function members are methods that define the object's behavior, like using the potion or displaying its effects. When you create an object, you can do so either on the stack or on the heap. Remember, these are two separate memory segments. Creating an object on the stack means it's automatically managed…
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)
-
-
-