for example
if we have a constructor
car(int a, int b){
car.model = a+b;
}
//another constructor
car( int a, int b){
car.model = a/b;
}
v = car(3, 4)
in this case which constructor will be called.
for example
if we have a constructor
car(int a, int b){
car.model = a+b;
}
//another constructor
car( int a, int b){
car.model = a/b;
}
v = car(3, 4)
in this case which constructor will be called.
hello @snatchit
no we cant do this within same class.
we have something called method overriding ( a concept of inhertance).
using that we can define two constructor with same paramenters but different functionality
read about inheritance and method overriding for more details
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.