/** @file list4401.cpp */
/** Listing 44-1. Using Conditional Expressions in a Constructor’s Initializer */
/// Construct a rational object from a numerator and a denominator.
/// If the denominator is zero, throw zero_denominator. If the denominator
/// is negative, normalize the value by negating the numerator and denominator.
/// @post denominator_ > 0
/// @throws zero_denominator
rational::rational(int num, int den)
: numerator_(den < 0 ? -num : num),
  denominator_(den == 0 ? throw zero_denominator("0 denominator") :
                          (den < 0 ? -den : den))
{
  reduce();
}
