Page 1 of 1

[HD-OCP17/21-Fundamentals Pg 0, Sec. 13.1.2 - inheriting-constructors-and-initializers]

Posted: Wed Nov 27, 2024 1:53 pm
by joaoclopes
Hello, in this example shouldn't we mention that it will never compile because Person class doesn't have no args constructor?

Thanks!

Re: [HD-OCP17/21-Fundamentals Pg 0, Sec. 13.1.2 - inheriting-constructors-and-initializers]

Posted: Wed Nov 27, 2024 9:35 pm
by admin
Right but if constructors were inherited, the Employee class would have inherited the String argument constructor from Person and the given code would have compiled. There would not have been a need for the no-args constructor in Person.

Re: [HD-OCP17/21-Fundamentals Pg 0, Sec. 13.1.2 - inheriting-constructors-and-initializers]

Posted: Thu Nov 28, 2024 8:10 pm
by joaoclopes
Got it! It was just to explain that constructors aren't inherited.

Thanks!