#include <iostream>

using namespace std;

class A{
    // class のメンバ変数は標準で private 
    double x;
public:
    // 以下は public 領域であり，外部から参照可能
    A sum_with(A a) // やりたいこと: (*this) + a;
    {
        A r;
        r.x = (*this).x + a.x;
        return r;
    }
    A diff_from(A a) // やりたいこと: (*this) - a;
    {
        A r;
        r.x = (*this).x - a.x;
        return r;
    }
    bool greater_than(A a) // やりたいこと: (*this) > a;
    {
        bool r;
        r = (*this).x > a.x;
        return r;
    }
    bool equal_to(A a){ // やりたいこと: (*this) == a;
        bool r;
        r = (*this).x == a.x;
        return r;
    }
    A mul_with(double s) // やりたいこと: (*this)*s; mul は multiply の略
    {
        A r;
        r.x = (*this).x*s;
        return r;
    }
    double& get_ref(){ // やりたいこと: (*this).x = something; ref は reference の略
        return (*this).x;
    }
    A move(A a){ // やりたいこと: (*this) = a; 数学における代入は英語で substitution だが，計算機では値を移動することから move とする．
        (*this).x = a.x;
        return (*this);
    }
    A& push(double a){ // やりたいこと: (*this) << a; これは数学にはない演算なので，わかりづらいと思うが，画面出力など情報を連続した流し込みを表現することが目標にあると思って欲しい．
        (*this).x += a; // 演習のためのただの例であり，push と名の付く関数は普通値の加算を意味しないことに注意せよ．
        return (*this); // 自分の参照を返せば，89 行目のように連続して呼び出すことができる．
    }
};

int main(){
    A a1, a2;

    a1.get_ref() = 1;
    a2.get_ref() = 2;

    cout << a1.get_ref() << ", " << a2.get_ref() << "\n";

    if(a1.greater_than(a2)){
        cout << a1.get_ref() << " > " << a2.get_ref() << "\n";
    }else{
        cout << a1.get_ref() << " < " << a2.get_ref() << "\n";
    }

    if(a1.equal_to(a2)){
        cout << a1.get_ref() << " == " << a2.get_ref() << "\n";
    }else{
        cout << a1.get_ref() << " != " << a2.get_ref() << "\n";
    }

    a1 = a1.sum_with(a2);
    cout << a1.get_ref() << ", " << a2.get_ref() << "\n";

    a1 = a1.diff_from(a2);
    cout << a1.get_ref() << ", " << a2.get_ref() << "\n";

    a1.move(a2);
    cout << a1.get_ref() << ", " << a2.get_ref() << "\n";

    a1 = a1.mul_with(2);
    cout << a1.get_ref() << "\n";
    a1 = a1.sum_with(a2.mul_with(2)); // a1 + a2*2;
    cout << a1.get_ref() << "\n";

    a1.push(2);
    cout << a1.get_ref() << "\n";

    a1.push(1).push(2).push(3);
    cout << a1.get_ref() << "\n";
    return 0;
}