Design Patterns
currency.h
Go to the documentation of this file.
1 // Based on "Design Patterns: Elements of Reusable Object-Oriented Software"
2 // book by Erich Gamma, John Vlissides, Ralph Johnson, and Richard Helm
3 //
4 // Created by Bartosz Rachwal. The National Institute of Advanced Industrial Science and Technology, Japan.
5 
6 #ifndef STRUCTURAL_COMPOSITE_CURRENCY_H_
7 #define STRUCTURAL_COMPOSITE_CURRENCY_H_
8 
9 namespace structural
10 {
11 namespace composite
12 {
13 class Currency
14 {
15  public:
16  explicit Currency(const double&);
17 
18  double value() const;
19  void value(double);
20 
21  friend bool operator==(const Currency& left, const Currency& right);
22  friend bool operator!=(const Currency& left, const Currency& right);
23 
24  private:
25  double value_;
26 };
27 
28 inline bool operator==(const Currency& left, const Currency& right)
29 {
30  return left.value() == right.value();
31 }
32 
33 inline bool operator!=(const Currency& left, const Currency& right)
34 {
35  return left.value() != right.value();
36 }
37 }
38 }
39 #endif
40 
Definition: shape_interface.h:11
Currency(const double &)
Definition: currrency.cc:12
Definition: currency.h:13
double value() const
Definition: currrency.cc:14
bool operator!=(const Currency &left, const Currency &right)
Definition: currency.h:33
friend bool operator==(const Currency &left, const Currency &right)
Definition: currency.h:28
friend bool operator!=(const Currency &left, const Currency &right)
Definition: currency.h:33
bool operator==(const Currency &left, const Currency &right)
Definition: currency.h:28