What is a Class?
This section will familiarize us with the basic building blocks of object-oriented programming: Classes.
We'll cover the following
Custom Objects
In C++, we have several different data types like int
, string
, bool
etc. An object can be created out of any of those types. An object is an instance of a class. Well, object-oriented programming wouldn’t make sense if we couldn’t make our own custom objects. This is where classes come into play.
Classes are used to create user-defined data types. We can use these basic data types to create our own class. The cool part is that our class can contain multiple variables, pointers, and functions which would be available to us whenever a class object is created.
Let’s start off with an example of a car class. Below, we can see that a car object would contain: