One way would be to define a base class called fruit, from which you could derive specific types of fruit, including an orange.
That would depend on your value assigned for banana, orange and tomato.
A kayak. Or, if orange was a fruit the new answer would be an octopus.
There are no drawbacks to multiple inheritance if multiple inheritance is precisely what is required to achieve your goal. If there are any drawbacks then it is only because of poor design, not multiple inheritance itself. For instance, when designing classes to simulate vehicles, an amphibious vehicle would inherit the properties of both an off-road vehicle and a marine vehicle, therefore multiple inheritance would be an appropriate usage.
Yes.
C++ allows multiple inheritance while Java does not. In my opinion, multiple inheritance is not useful because it can get very confusing very quick. For polymorphism, C++ does early binding by default, while Java does late binding by default. Late binding is more useful than early binding.
struct A {}; // base class struct B : A {} // derived class (single inheritance).
It cannot. Inheritance is a compile-time operation. Constructors are invoked at runtime at the point of instantiation.
struct base1 { // ... }; struct base2 { // ... }; struct derived1 : public base1 // single inheritance { // ... }; struct derived2 : public base1, public base2 // multiple inheritance { // ... };
Red + Yellow = Orange
red-orange
orange
Red Orange Yellow*GreenBlue Indigo VioletRed is to Orange: Blue is to Indigo.INDIGO.AnswerRed is to orange as blue is to green. Red plus yellow is orange; blue plus yellow is green.