Public Member Functions | Private Attributes | List of all members
arttest::Fraction Class Reference

#include <Fraction.h>

Public Member Functions

 Fraction ()=default
 
 Fraction (unsigned const num, unsigned const denom)
 
double value () const
 
double numerator () const
 
void aggregate (Fraction const &f)
 

Private Attributes

unsigned num_ {-1u}
 
unsigned denom_ {-1u}
 

Detailed Description

Definition at line 6 of file Fraction.h.

Constructor & Destructor Documentation

arttest::Fraction::Fraction ( )
default
arttest::Fraction::Fraction ( unsigned const  num,
unsigned const  denom 
)
inline

Definition at line 10 of file Fraction.h.

11  : num_{num}, denom_{denom}
12  {}
unsigned denom_
Definition: Fraction.h:35
unsigned num_
Definition: Fraction.h:34

Member Function Documentation

void arttest::Fraction::aggregate ( Fraction const &  f)
inline

Definition at line 27 of file Fraction.h.

28  {
29  num_ += f.num_;
30  denom_ += f.denom_;
31  }
unsigned denom_
Definition: Fraction.h:35
unsigned num_
Definition: Fraction.h:34
double arttest::Fraction::numerator ( ) const
inline

Definition at line 21 of file Fraction.h.

22  {
23  return num_;
24  }
unsigned num_
Definition: Fraction.h:34
double arttest::Fraction::value ( ) const
inline

Definition at line 15 of file Fraction.h.

16  {
17  return denom_ == 0. ? 0. : static_cast<double>(num_) / denom_;
18  }
unsigned denom_
Definition: Fraction.h:35
unsigned num_
Definition: Fraction.h:34

Member Data Documentation

unsigned arttest::Fraction::denom_ {-1u}
private

Definition at line 35 of file Fraction.h.

unsigned arttest::Fraction::num_ {-1u}
private

Definition at line 34 of file Fraction.h.


The documentation for this class was generated from the following file: