Computer Science, asked by shyam5088, 10 months ago

constructer overloading​

Answers

Answered by ScarlettIsla
2

➡When many constructors have same name, it is known as Constructor overloading.

{All Constructors have same name as the class name}

Hope it helps you ✌

Answered by SerenaBochenek
0

Constructor overloading:  The word overloading means to perform different tasks using the same method. Constructor are overloaded to perform different tasks as we do for methods.      

Explanation:

To overload a constructor within a program, the user needs to pass different parameters inside the parameter list of the constructor.

Below is the syntax to understand the constructor overloading:

Syntax:

public class XYZ

{

public:

         //default constructor

         XYZ()

         {

          //code block       

         }

         //overloaded constructor

         XYZ(int a)

         {

        //code block

         }

        //overloaded constructor

         XYZ(int b)

         {

         //code block 

         }

}

Learn more:

https://brainly.in/question/5796337

https://brainly.in/question/10500209

Similar questions