C_CPP/04_UDEF/RationalNumber.cpp

29 lines
705 B
C++

// file: RationalNumber.cpp
#include "RationalNumber.hpp"
RationalNumber addRationalNumbers(RationalNumber left, RationalNumber right){
RationalNumber result = left;
// add left and right
return result;
}
RationalNumber operator+ (RationalNumber left, RationalNumber right){
return addRationalNumbers(left, right);
}
// for println()
std::string as_string(RationalNumber r){
std::string result = "(";
result += std::to_string(r.zaehler);
result += "/";
result += std::to_string(r.nenner);
result += ")";
return result;
}
/*std::ostream& operator<< (std::ostream& os, RationalNumber &toBePrinted){
os << "(" << toBePrinted.zaehler << "/"
<< toBePrinted.nenner << ")";
return os;
}*/