🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to C++ Notes
Topic #90

Constructor Overloading


Constructor Overloading

In C++, you can have more than one constructor in the same class. This is called constructor overloading.

Each constructor must have a different number or type of parameters, so the compiler knows which one to use when you create an object.


Why Use Constructor Overloading?

  • To give flexibility when creating objects
  • To set default or custom values
  • To reduce repetitive code

Example with Two Constructors

This class has two constructors: one without parameters, and one with parameters:

class Car {
  public:
    string brand;

string model;

    Car() {

brand = "Unknown";
      model = "Unknown";

}

    Car(string b, string m) {

brand = b;
      model = m;

}
};

int main() {
  Car car1;

Car car2("BMW", "X5");
  Car car3("Ford", "Mustang");

cout << "Car1: " << car1.brand << " " << car1.model << "\n";
  cout <<
"Car2: " << car2.brand << " " << car2.model << "\n";
  cout << "Car3:
" << car3.brand << " " << car3.model;
  return 0;
}

Constructor overloading lets you create objects with custom values.

Want to go beyond the notes?

Join CodingNow 2.0's C++ course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Constructor Overloading – FAQs

Quick answers about learning Constructor Overloading in C++.

This free note from CodingNow 2.0 explains Constructor Overloading in C++ — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every C++ topic on CodingNow 2.0, including Constructor Overloading, is 100% free with no signup required.
With focused practice, most students grasp Constructor Overloading in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now