C# Tutorial for Beginners #26 - Abstraction with Abstract Classes and Methods

preview_player
Показать описание
Learning about and implementing abstraction with abstract classes and methods, as well as making good use of the override keyword. Make that inheritance stronger!!

Highly recommend you watch #24/25 before this video if you are not familiar with inheritance.

Please let me know if you have any questions. Happy coding!

Chapters:
0:00 Introduction
0:14 Setup
0:33 Abstraction Basics
3:25 Abstract Methods
6:34 Further Overriding Methods
9:11 Next Up
Рекомендации по теме
Комментарии
Автор

When we say Person person = doctor; We are assigning the person variable of type Person to the doctor object which has the override method. So that's why we get the override method results and the reason why the complier allows this is because we're not making a new person. We are just assigning a variable to an existing object which is also of the same type due to inheritance. Am I understanding this correctly?

It makes sense to me why it works, but I'm trying to think of a use case of why you may want to assign the doctor object back to a person variable in a real life scenario.

MethodOverRide