What's the point of implementing the Bridge pattern with multiple inheritance? The way GoF explains it in their Design Patterns book makes it seem counterintuitive to the Intent.
Also, why does multiple inheritance disqualify the implementation from being a true Bridge pattern?
Examples are much appreciated.
This is all explained in the Implementation issues #4.
Using multiple inheritance. You can use multiple inheritance in C++ to combine an interface with its implementation. For example, a class can inherit publicly from
Abstraction
and privately from aConcretelmplementor
. But because this approach relies on static inheritance, it binds an implementation permanently to its interface. Therefore you can't implement a true Bridge with multiple inheritance—at least not in C++.
So...
What's the point of implementing the Bridge pattern with multiple inheritance?
You can't.
The way GoF explains it in their Design Patterns book makes it seem counterintuitive to the Intent.
It is. That's why you can't do it.
why does multiple inheritance disqualify the implementation from being a true Bridge pattern?
"because this approach relies on static inheritance," [p. 156] and "Inheritance binds an implementation to the abstraction permanently, which makes it difficult to modify, extend, and reuse abstractions and implementations independently." [p. 151] ...which is the motivation for a Bridge.
Honestly, I'm not entirely sure why the GoF felt the need to bring up multiple inheritance in the Bridge chapter at all, but the conversation seems to go something like this.