1.

Briefly explain the concept of constructor overloading

Answer»

Constructor overloading is the process of creating multiple constructors in the class consisting of the same name with a difference in the constructor parameters. Depending UPON the number of parameters and their corresponding types, distinguishing of the different types of constructors is done by the compiler.

class Hospital {INT variable1, VARIABLE2;double VARIABLE3;public Hospital(int DOCTORS, int nurses) { variable1 = doctors; variable2 = nurses;}public Hospital(int doctors) { variable1 = doctors;}public Hospital(double salaries) { variable3 = salaries}}

Three constructors are defined here but they differ on the basis of parameter type and their numbers.



Discussion

No Comment Found