Constructor Overloading in C++Last Updated : 11 Jan 2026 In C++, constructor overloading is an important feature in OOPs (Object-Oriented Programming) that allows a class to have several constructors with different parameters. Several constructor variants with distinct argument lists can be defined to create objects in various ways. The class instance is determined by the compiler using the type and number of parameters. Thus, code becomes more flexible and readable. In C++, constructors overloaded essentially follow the same name (the exact name of the class). A constructor is invoked based on the number and argument types that are passed in the program. However, they vary in the number and type of arguments they accept. SyntaxIt has the following syntax: Explanation: In this example, we use multiple constructor definitions to create a C++ class called Class_name that demonstrates constructor overloading. After that, the class includes parameterized constructors that accept one, two, or three parameters. Each of these constructors initializes the data members of the class based on the values entered at object creation. The names paramnum, paramnum1, and paramnum2 are simply placeholders for the names and types of actual variables (e.g., string, int). C++ Constructor Overloading ExampleLet us take a simple example of constructor overloading that uses a class named Student to show different ways in which objects can be initialized. ExampleCompile and RunOutput: Default constructor called. Constructor with name called. Constructor with name and age called. Constructor with name, age, and grade called. Student 1: Name: Unknown, Age: 0, Grade: 0 Student 2: Name: Alice, Age: 0, Grade: 0 Student 3: Name: Bob, Age: 20, Grade: 0 Student 4: Name: Charlie, Age: 21, Grade: 88.5 Explanation: In this example, we demonstrate the constructor overloading using a Student class with multiple constructors. Here, every constructor initializes the student's name, age, and grade based on the provided arguments. After that, the suitable constructor is invoked depending on how many values are passed during object creation. Finally, we use the display() function to print the details of every student. How Constructor Overloading Works in C++?In C++, if we want to create an object, the compiler selects the best constructor based on the arguments that we pass. Constructor overloading enables us to define several constructors with different parameters lists. After that, the compiler will choose the constructor which matches the number and type of arguments that are provided during the object creation. C++ Constructor Overloading ExampleLet us take an example to illustrate how constructor overloading works in C++. ExampleCompile and RunOutput: Default constructor called. Constructor with title called. Constructor with title and author called. Constructor with title, author, and price called. Book 1: Title: Untitled, Author: Unknown, Price: $0 Book 2: Title: The Alchemist, Author: Unknown, Price: $0 Book 3: Title: 1984, Author: George Orwell, Price: $0 Book 4: Title: Dune, Author: Frank Herbert, Price: $19.99 Explanation: In this example, we use a Book class with three data members: title, author, and price. All fields are initialized with default values by the default constructor. After that, the display() function is used to print the book details, which shows how each constructor sets default or given values. This method helps to improve the flexibility in object initialization. Benefits of Constructor Overloading in C++There are several features of constructor overloading in C++. Some main features are as follows:
ConclusionIn conclusion, constructor overloading is an important feature of C++ OOPs. Constructor overloading is a feature that allows a class can have several constructors, each with a different list of parameters. Hence, objects can be created in various ways based on the data available. Object initialization becomes easier and more efficient with increased flexibility, readability, and code reusability. In C++, overloaded constructors give the developer the ability to provide partial initialization, full initialization, or default values based on the use case. As a whole, constructor overloading helps achieve more versatility and utility while developing classes, which makes them an essential part of the system. Next TopicC++ Copy Constructor |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India