← Back to question

Answer explained

What is a constructor in C++?

A constructor is a special class member with the same name as the class and no return type. It runs automatically when an object is created to initialize members and resources.