✅ Difficulty understanding Inheritance and where to use Constructor
Hello people. I'm learning OOP and I've come across this problem. I'm creating a Football team creator console app. I have a abstract class called Player which has the base properties. I have four inherited classes (Defender, Midfielder, etc) which all have different skill properties(Passing, Shooting etc).
I have two Questions:
1. Where(in Player or in inherited classes) and how do I put the constructor so it inherits all the properties of Player.
2. I have a DisplayInfo() method in Player Class. I want to use this method in inhertied classes but add additional functionalities to display the skill properties.
Code:
1. Abstract Player Class
2. inherited Defender Class
3 Replies
1. Do you mean the
base
constructor?
2. Parent has no knowledge of its children. You can make the method virtual
maybe so it can be override
n in the childrenWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.thanks a lot. i got it now with base constructor