Isn't it unnecessary to connect in inherited classes?
Inheritance makes OOP a powerful concept.
There are so many problems of same nature. by use of inheritance, you will able to solve them efficiently. (I know it may look like an alien thing to say if you're completely new to oop)
Tho I will help you to understand basic difference between Class, Instance and Object. (because you will see it is being used a lot in Python OOP section)
This answer I got from www.quora.com , I hope it will clear your concepts!
Lets say you want to create a horrifying boogeyman. So, you take a pen and a paper and start noting down what will your boogeyman look like.
- Long hairs
- Red Body
- Swollen eyes
And what your boogeyman does
- Attacks and kills people when he sees them
- Eats brain
- Sleeps with noise
- Draws blood from the neck
- So, your boogeyman is ready to be manufactured based on the above guidelines.
Now, you give these details to Boogeymaker, who can make you your own real life boogeyman. Although if you ask him how does he manufacture one, he may not tell
Lets say you want 4 of them. After a few hours the boogeymaker comes back and gives you your own 4 boogeymen with which, it is time you go scaring away others.
But, hey, here is a problem. All boogeymen are identical, thanks to the accurate guidelines. How do I ask one boogyman to attack and the other to eat brain? Well,
simple I name them say boogey1, boogey2, boogey3, boogey4
Guidelines/Template that your created for the boogeyman is your class.
The 4 boogeymen supplied by the boogeymaker is your objects
The 4 names that you assigned to your boogey army is your instances
(Thanks to original poster of this Answer)
Back to inheritance:
You can delete your solution(by editing)
note don't share your final working code as other fellow learners can copy ,paste and use it.