Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAlex Hort-Francis
12,924 PointsConfusion: setting the `$description` property on `ListingPremium` to `protected`, at 1:30
I think the way this is explained is a bit confusing. Alena talks about how properties with a protected
access visibility on a child class are available to the parent class if there is a method that uses a property of the same name in the parent class, and the parent class declares that property, as protected
.
This makes sense in terms of scoping, but confused me because it sounded like the inheritance was going 'back up the chain', which is not how object-oriented programming works.
Only child classes can inherit from parent classes, not the other way around.
A better way to explain this may be to just delete the $description
property from the ListingPremium
child class, as it doesn't need to be declared in both the parent and child classes.
Have I got this right?