/* * rational.cpp * * Created on: 28.02.2013 * Author: trifon */ #include using namespace std; #include "rational.h" Rational::Rational() { // this->numer = 0; // this->denom = 0; // !!!!! this = that; numer = 0; denom = 1; } Rational::Rational(int n, int d) { numer = n; denom = d; } int Rational::getNumerator() const { return numer; } int Rational::getDenominator() const { return denom; } void Rational::print() const { cout << numer << '/' << denom << endl; } void Rational::read() { cout << "Числител: "; cin >> numer; cout << "Знаменател: "; cin >> denom; } Rational add(Rational p, Rational q) { return Rational( p.getNumerator() * q.getDenominator() + p.getDenominator() * q.getNumerator(), p.getDenominator() * q.getDenominator()); }