#include <iostream>
#include <string>
using namespace std;
class Number;
class Integer;
class Rational;
class Number
{
public:
int num, den;
virtual void add(Number&) = 0;
virtual void addInteger(Integer&) = 0;
virtual void addRational(Rational&) = 0;
virtual string toString() = 0;
};
class Rational : public Number
{
void addInteger(Integer& i);
void addRational(Rational &r);
public:
void add(Number& n)
{
n.addRational(*this);
}
Rational(int n, int d)
{
this->num = n;
this->den = d;
}
};
class Integer : public Number
{
void addInteger(Integer& i);
void addRational(Rational& r);
public:
void add(Number& n)
{
n.addInteger(*this);
}
Integer(int n)
{
this->num = n;
this->den = 1;
}
};
void Rational::addInteger(Integer& i)
{
this->num = this->num + i.num*this->den;
this->den = this->den;
cout << this->num << "/" << this->den;
}
void Rational::addRational(Rational &r)
{
this->num = this->num*r.den + this->den*r.num;
this->den = this->den*r.den;
cout << this->num << "/" << this->den;
}
void Integer::addInteger(Integer& i)
{
this->num += i.num;
this->den = 1;
cout << this->num;
}
void Integer::addRational(Rational& r)
{
this->num = this->num*r.den + r.num;
this->den = r.den;
cout << "this->num" << "/" << this->den;
}
int main()
{
cout << "Helo World";
return 0;
}