Multiple Inheritance Flashcards

1
Q

What is Multiple Inheritance?

A

The concept of a class being able to inherit properties from more than one base class. Classes are not limited to a single base class.

Example code:

// Derived class inheriting from both Shape and Color
class Circle : public Shape, public Color
{
public:
void drawCircle()
{
cout &laquo_space;“Drawing a “ &laquo_space;getColor() &laquo_space;”
circle” &laquo_space;endl;
}
};

int main()
{
Circle c;
c.setColor(“red”);
c.draw(); // Inherited from Shape
c.drawCircle();

return 0; }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Do all object-oriented programming languages support multiple inheritance?

A

No.

C++ does, but Java does not.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly