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 «_space;“Drawing a “ «_space;getColor() «_space;”
circle” «_space;endl;
}
};
int main()
{
Circle c;
c.setColor(“red”);
c.draw(); // Inherited from Shape
c.drawCircle();
return 0; }
2
Q
Do all object-oriented programming languages support multiple inheritance?
A
No.
C++ does, but Java does not.