Log in from a computer to take this course

You'll need to log in from a computer to start Learn C++. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store

So far, we’ve used several data types, including int, double, std::string, and bool. When we work with int or std::string, we can create variables with certain properties and methods specific to those types. For example:

int age = 33; age++; // age is now 34

But what happens when you want to create a “type” for something else? You can make your own! Bjarne Stroustrup developed C++ because he wanted to add a feature known as “classes” to the C language. A C++ class is a user-defined type.

The class serves as a blueprint for objects, which are instances of the class (just like age is an instance of int). An object gets characteristics and behaviors from its class.

We can create an empty C++ class like this in a header file:

class City { }; // <-- notice this semicolon!

Fun fact: C++’s original name was “C with Classes.”



Create a new class Song in song.hpp.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?