What is Constructor Overloading?

Constructor overloading means defining more than one constructor or multiple constructors in a single class where each constructor have different arguments. In case of constructor overloading, compiler will call different constructors by checking their data types, the number of arguments of the constructors and their order.

Eg of Constructor overloading:
Class area
{
Double ar;
Public:
Area(int s)
{
Ar=s*s;
}
Area(int l,int b)
{
Ar=l*b;
}
Area(float r);
{
Ar=3.142*r*r;
}

More Questions

Leave a Reply

Word Verfication * Time limit is exhausted. Please reload CAPTCHA.