Get Mystery Box with random crypto!

C++ Constructors In this tutorial, we will learn about the C+ | C

C++ Constructors

In this tutorial, we will learn about the C++ constructor and its type with the help examples.

A constructor is a special type of member function that is called automatically when an object is created.

In C++, a constructor has the same name as that of the class and it does not have a return type. For example,

class Wall {
public:
// create a constructor
Wall() {
// code
}
};

Here, the function Wall() is a constructor of the class Wall. Notice that the constructor

has the same name as the class,
does not have a return type, and
is public