-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWildTurkeyAdapter.hpp
More file actions
29 lines (24 loc) · 743 Bytes
/
WildTurkeyAdapter.hpp
File metadata and controls
29 lines (24 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef WILD_TURKEY_ADAPTER_H
#define WILD_TURKEY_ADAPTER_H
#include "Duck.hpp"
#include "Turkey.hpp"
#include "WildTurkey.hpp"
#include <iostream>
/*
* Multiple Inheritance:
* Inherit publicly from target (Duck) and privately from adaptee (WildTurky) thus the adapter would be a subclass of target but not the adaptee (Design Pattern, 144). The former is an interface (abstract) while the later is an implimentation (concrete).
*/
class WildTurkeyAdapter : public Duck, private WildTurkey {
public:
WildTurkeyAdapter() = default;
void quack() override { WildTurkey::gobble(); }
void fly() override;
};
inline
void
WildTurkeyAdapter::fly()
{
for (int i = 0; i < 5; ++i)
WildTurkey::fly();
}
#endif /* WILD_TURKEY_ADAPTER_H */