C_CPP/04_UDEF/RationalNumber.cpp

29 lines
698 B
C++
Raw Normal View History

2018-03-09 09:47:53 +01:00
// file: RationalNumber.cpp
#include "RationalNumber.hpp"
RationalNumber addRationalNumbers(RationalNumber left, RationalNumber right){
RationalNumber result;
// 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;
}*/