+ 4
Let's say we have three classes "A", "B" and "C". Can "C" class inherit from both "A & B" classes?
7 RĂ©ponses
+ 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