Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Fraction
- {
- private:
- int value, x, y, z;
- public:
- Fraction::Fraction() {};
- Fraction(int a) : value(a) {};
- friend const Fraction& operator+(const Fraction& a);
- friend const Fraction operator-(const Fraction& a);
- friend const Fraction& operator*(const Fraction& a);
- friend const Fraction& operator/(const Fraction& a, const Fraction& b);
- friend bool operator==(const Fraction& a, const Fraction& b);
- Fraction& operator=(const Fraction& a)
- {
- if (this == &a)
- {
- return *this;
- }
- value = a.value;
- return *this;
- }
- friend bool operator!=(const Fraction &a, const Fraction &b);
- friend bool operator<(Fraction const & a, Fraction const & b);
- friend bool operator>(Fraction const & a, Fraction const & b);
- friend ostream& operator << (ostream &a, const Fraction &b);
- friend istream& operator >> (istream &a, Fraction &b);
- };
- const Fraction& operator+(const Fraction& a)
- {
- return a.value;
- }
- const Fraction operator-(const Fraction& a)
- {
- return Fraction(-a.value);
- }
- const Fraction& operator*(const Fraction& a)
- {
- return a.value;
- }
- const Fraction& operator/(const Fraction& a, const Fraction& b)
- {
- return Fraction(-a.value);
- }
- bool operator==(const Fraction& a, const Fraction& b)
- {
- return a.value == b.value;
- }
- bool operator!=(const Fraction &a, const Fraction &b)
- {
- return !(a == b);
- }
- bool operator <(Fraction const & a, Fraction const & b)
- {
- return a < b;
- }
- bool operator >(Fraction const & a, Fraction const & b)
- {
- return a > b;
- }
- ostream& operator << (ostream &a, const Fraction &b)
- {
- a << '(' << b.x << ", " << b.y << ", " << b.z << ')';
- return a;
- }
- istream& operator >> (istream &a, Fraction &b)
- {
- cout << "Введите Fraction.\nX:";
- cin >> b.x;
- cout << "\nY:";
- cin >> b.y;
- cout << "\nZ:";
- cin >> b.z;
- cout << endl;
- return a;
- }
- int main() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement