Hello, in this example shouldn't we mention that it will never compile because Person class doesn't have no args constructor?
Thanks!
[HD-OCP17/21-Fundamentals Pg 0, Sec. 13.1.2 - inheriting-constructors-and-initializers]
Moderator: admin
-
- Posts: 16
- Joined: Mon Sep 23, 2024 4:49 pm
- Contact:
-
- Site Admin
- Posts: 10263
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD-OCP17/21-Fundamentals Pg 0, Sec. 13.1.2 - inheriting-constructors-and-initializers]
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.
If you like our products and services, please help us by posting your review here.
-
- Posts: 16
- Joined: Mon Sep 23, 2024 4:49 pm
- Contact:
Re: [HD-OCP17/21-Fundamentals Pg 0, Sec. 13.1.2 - inheriting-constructors-and-initializers]
Got it! It was just to explain that constructors aren't inherited.
Thanks!
Thanks!
Who is online
Users browsing this forum: No registered users and 9 guests