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

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