Design patterns implementation examples

Adapter (Class implementation)

Definition:

Converts one class interface to another. Adds existing class new inteface statically which better fits to existing code.


Example:

A real-life example is an adapter for instance USB - HDMI. Let's say we have a computer which has USB input, but we bought a TV with HDMI input, in order for both devices to work together we need to buy an adapter.


C++ code:

/src/adapterclass.cpp
Download source code

Adapter UML class diagram:
Adapter UML class diagram

Adapter UML sequence diagram:
Adapter UML sequence diagram