+ 4
Let's say we have three classes "A", "B" and "C". Can "C" class inherit from both "A & B" classes?
7 odpowiedzi
+ 12
No as multiple inheritance of classes is not allowed
Edit: Sorry, I was mistaken, multiple inheritance is allowed in C++
+ 9
It's allowed in C++ but it won't be meaningful if Cat class is inherited from class Dog, because a cat is not a dog. You can decide whether you should use Inheritance relationship or not by thinking of "IS-A" relationship.
If "class A is a class B" makes sense, then B is the parent class and A is a child class of B.
Let's consider the following statements:
Animal is a Dog - ❌
Animal is a Cat - ❌
Dog is an Animal - ✅
Dog is a Cat - ❌
Cat is an Animal - ✅
Cat is a Dog - ❌
So, Animal should be the parent class and both Dog 🐶 and Cat 🐱 should be it's child classes.
+ 6
yerucham he never told you it was in java😂😂
+ 6
Oh boy
+ 6
It's allowed in mandarin,a Chinese based half OOP language I guess
+ 3
Thanks @Yerucham.
+ 1
yes c++ support multiple inheritance while in java it isn't possible that's where interfaces come to play