Prerequisites: Constructors in C++
In C++, We can have more than one constructor in a class with same name, as long as each has a different list of arguments.This concept is known as Constructor Overloading and is quite similar to function overloading.
- Overloaded constructors essentially have the same name (name of the class) and different number of arguments.
- A constructor is called depending upon the number and type of arguments passed.
- While creating the object, arguments must be passed to let compiler know, which constructor needs to be called.
Related Articles :
- Destructors in C++
- quiz on constructors in C++
- Output of C++ programs | Set 26 (Constructors)
- Output of C++ programs | Set 27(Constructors and Destructors)
This article is contributed by I.HARISH KUMAR. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Operator Overloading in C++
- Function Overloading in C++
- Does overloading work with Inheritance?
- Function Overloading and float in C++
- Overloading New and Delete operator in c++
- C++ | Operator Overloading | Question 10
- Types of Operator Overloading in C++
- Rules for operator overloading
- Increment (++) and Decrement (--) operator overloading in C++
- Overloading stream insertion (<>) operators in C++
- Function overloading and return type
- Function overloading and const keyword
- Constructor Delegation in C++
- Copy Constructor in C++
- Can a constructor be private in C++ ?
- What is conversion constructor in C++?
- C++ program to compare two Strings using Operator Overloading
- C++ Program to concatenate two strings using Operator Overloading
- Overloading Subscript or array index operator  in C++
- Operator overloading in C++ to print contents of vector, map, pair, ..