Project 3 - Currency Type

- Main Page
- Classes
- Files

- File List
- File Members

Classes | Functions
currency.hpp File Reference
`#include <iomanip>`
`#include <istream>`
`#include <locale>`
`#include <ostream>`
`#include <sstream>`
`#include <string>`
`#include <stdexcept>`
`#include "ioflags.hpp"`
`#include "fixed.hpp"`
`#include "rational.hpp"`

Go to the source code of this file.

## Classes
class | currency< T, N >

## Functions
template<class T , int N, class Char , class Traits >
std::basic_istream< Char, Traits > & | operator>> (std::basic_istream< Char, Traits > &strm, currency< T, N > &c)
template<class T , int N, class Char , class Traits >
std::basic_ostream< Char, Traits > & | operator<< (std::basic_ostream< Char, Traits > &strm, currency< T, N > c)
template<class T , int N>
currency< T, N > | operator- (currency< T, N > a)
| Negate a currency value.
template<class T , int N>
currency< T, N > | operator+ (currency< T, N > a, currency< T, N > b)
template<class T , int N>
currency< T, N > | operator- (currency< T, N > a, currency< T, N > b)
template<class T , int N>
currency< T, N > | operator* (currency< T, N > a, T b)
template<class T , int N>
currency< T, N > | operator* (T a, currency< T, N > b)
template<class T , int N>
currency< T, N > | operator/ (currency< T, N > a, T b)
template<class T , int N>
rational< T > | operator/ (currency< T, N > n, currency< T, N > d)
template<class T , int N>
bool | operator== (currency< T, N > a, currency< T, N > b)
template<class T , int N>
bool | operator== (currency< T, N > a, T b)
template<class T , int N>
bool | operator== (T a, currency< T, N > b)
template<class T , int N>
bool | operator!= (currency< T, N > a, currency< T, N > b)
template<class T , int N>
bool | operator!= (currency< T, N > a, T b)
template<class T , int N>
bool | operator!= (T a, currency< T, N > b)
template<class T , int N>
bool | operator< (currency< T, N > a, currency< T, N > b)
template<class T , int N>
bool | operator< (currency< T, N > a, T b)
template<class T , int N>
bool | operator< (T a, currency< T, N > b)
template<class T , int N>
bool | operator> (currency< T, N > a, currency< T, N > b)
template<class T , int N>
bool | operator> (currency< T, N > a, T b)
template<class T , int N>
bool | operator> (T a, currency< T, N > b)
template<class T , int N>
bool | operator<= (currency< T, N > a, currency< T, N > b)
template<class T , int N>
bool | operator<= (currency< T, N > a, T b)
template<class T , int N>
bool | operator<= (T a, currency< T, N > b)
template<class T , int N>
bool | operator>= (currency< T, N > a, currency< T, N > b)
template<class T , int N>
bool | operator>= (currency< T, N > a, T b)
template<class T , int N>
bool | operator>= (T a, currency< T, N > b)

## Detailed Description

Implement a currency type.

Definition in file currency.hpp.

## Function Documentation

template<class T , int N>

bool operator!= | ( | currency< T, N > | a,
|  | currency< T, N > | b
| ) |  |
| inline

Compare currency values for inequality.

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 391 of file currency.hpp.

template<class T , int N>

bool operator!= | ( | currency< T, N > | a,
|  | T | b
| ) |  |
| inline

Compare currency value and an integer for inequality

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 399 of file currency.hpp.

template<class T , int N>

bool operator!= | ( | T | a,
|  | currency< T, N > | b
| ) |  |
| inline

Compare currency value and an integer for inequality

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 407 of file currency.hpp.

template<class T , int N>

currency<T,N> operator* | ( | currency< T, N > | a,
|  | T | b
| ) |  |

Multiply currency value and an integer

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 324 of file currency.hpp.

template<class T , int N>

currency<T,N> operator* | ( | T | a,
|  | currency< T, N > | b
| ) |  |

Multiply currency value and an integer

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 334 of file currency.hpp.

template<class T , int N>

currency<T,N> operator+ | ( | currency< T, N > | a,
|  | currency< T, N > | b
| ) |  |

Add currency values

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 304 of file currency.hpp.

template<class T , int N>

currency<T,N> operator- | ( | currency< T, N > | a,
|  | currency< T, N > | b
| ) |  |

Subtract currency values

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 314 of file currency.hpp.

template<class T , int N>

currency<T,N> operator/ | ( | currency< T, N > | a,
|  | T | b
| ) |  |

Divide currency value by an integer

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 344 of file currency.hpp.

template<class T , int N>

rational<T> operator/ | ( | currency< T, N > | n,
|  | currency< T, N > | d
| ) |  |

Divide currency values to yield a rational result.

Parameters

  n | the numerator
  d | the denominator

Definition at line 354 of file currency.hpp.

References fixed< T, N >::value(), and currency< T, N >::value().

template<class T , int N>

bool operator< | ( | currency< T, N > | a,
|  | currency< T, N > | b
| ) |  |

Compare currency values for less-than by comparing the underlying values.

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 416 of file currency.hpp.

References fixed< T, N >::value(), and currency< T, N >::value().

template<class T , int N>

bool operator< | ( | currency< T, N > | a,
|  | T | b
| ) |  |

Compare a currency value and an integer for less-than.

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 424 of file currency.hpp.

template<class T , int N>

bool operator< | ( | T | a,
|  | currency< T, N > | b
| ) |  |

Compare a currency value and an integer for less-than.

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 432 of file currency.hpp.

template<class T , int N, class Char , class Traits >

std::basic_ostream<Char, Traits>& operator<< | ( | std::basic_ostream< Char, Traits > & | strm,
|  | currency< T, N > | c
| ) |  |

Write a currency value

Parameters

  strm | The output stream
  c | The value to write

Definition at line 285 of file currency.hpp.

template<class T , int N>

bool operator<= | ( | currency< T, N > | a,
|  | currency< T, N > | b
| ) |  |
| inline

Compare currency values for less-than-or-equal.

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 466 of file currency.hpp.

template<class T , int N>

bool operator<= | ( | currency< T, N > | a,
|  | T | b
| ) |  |
| inline

Compare a currency value and an integer for less-than-or-equal.

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 474 of file currency.hpp.

template<class T , int N>

bool operator<= | ( | T | a,
|  | currency< T, N > | b
| ) |  |
| inline

Compare a currency value and an integer for less-than-or-equal.

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 482 of file currency.hpp.

template<class T , int N>

bool operator== | ( | currency< T, N > | a,
|  | currency< T, N > | b
| ) |  |

Compare currency values for equality by comparing the underlying values.

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 366 of file currency.hpp.

References currency< T, N >::value().

template<class T , int N>

bool operator== | ( | currency< T, N > | a,
|  | T | b
| ) |  |

Compare currency value and an integer for equality

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 374 of file currency.hpp.

References currency< T, N >::value().

template<class T , int N>

bool operator== | ( | T | a,
|  | currency< T, N > | b
| ) |  |

Compare currency value and an integer for equality

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 382 of file currency.hpp.

References currency< T, N >::value().

template<class T , int N>

bool operator> | ( | currency< T, N > | a,
|  | currency< T, N > | b
| ) |  |
| inline

Compare currency values for greater-than.

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 441 of file currency.hpp.

template<class T , int N>

bool operator> | ( | currency< T, N > | a,
|  | T | b
| ) |  |
| inline

Compare a currency value and an integer for greater-than.

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 449 of file currency.hpp.

template<class T , int N>

bool operator> | ( | T | a,
|  | currency< T, N > | b
| ) |  |
| inline

Compare a currency value and an integer for greater-than.

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 457 of file currency.hpp.

template<class T , int N>

bool operator>= | ( | currency< T, N > | a,
|  | currency< T, N > | b
| ) |  |
| inline

Compare currency values for greater-than-or-equal.

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 491 of file currency.hpp.

template<class T , int N>

bool operator>= | ( | currency< T, N > | a,
|  | T | b
| ) |  |
| inline

Compare a currency value and an integer for greater-than-or-equal.

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 499 of file currency.hpp.

template<class T , int N>

bool operator>= | ( | T | a,
|  | currency< T, N > | b
| ) |  |
| inline

Compare a currency value and an integer for greater-than-or-equal.

Parameters

  a | The left-hand operand
  b | The right-hand operand

Definition at line 507 of file currency.hpp.

template<class T , int N, class Char , class Traits >

std::basic_istream<Char, Traits>& operator>> | ( | std::basic_istream< Char, Traits > & | strm,
|  | currency< T, N > & | c
| ) |  |

Read a currency value

Parameters

  | strm | The input stream
  [out] | c | Store the value here

Definition at line 274 of file currency.hpp.

References currency< T, N >::read().