Base Constructor in Derived Class | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Base Constructor in Derived Class

I have a Chef base class and Italianchef subclass. I want the ItalianChef class to call the base constructor everytime an object of ItalianChef or other subclass of Chef is created. Can you call the parameter Chef(name, rating, age) constructor inside the empty Chef () constructor? Or... Can you call the ItalianChef constructor to print the Chef(name, rating, age) parameter constructor? The code will run for an object of ItalianChef, but only the ItalianChef constructor is called. (Code inside Dev C++)

4th Sep 2019, 6:21 PM
Seij Bailey
Seij Bailey - avatar
1 Answer
+ 2
when we create an object from derived class a constructor of base classes will be revoked but sometimes you have to determine which constructor should called check this code https://code.sololearn.com/cAN1CtdllqI8/?ref=app
4th Sep 2019, 7:15 PM
ABADA S
ABADA S - avatar