#include <iostream>

using namespace std;

class A{
    // class のメンバ変数は標準で private 
    double x;
public:
    // 以下は public 領域であり，外部から参照可能
    A operator+(A a) // やりたいこと: (*this) + a;
    {
        A r;
        r.x = (*this).x + a.x;
        return r;
    }
    bool operator>(A a) // やりたいこと: (*this) > a;
    {
        bool r;
        r = (*this).x > a.x;
        return r;
    }
    bool operator==(A a){ // やりたいこと: (*this) == a;
        bool r;
        r = (*this).x == a.x;
        return r;
    }
    A operator*(double s) // やりたいこと: (*this)*s; mul は multiply の略
    {
        A r;
        r.x = (*this).x*s;
        return r;
    }
    double& operator[](int i){ // やりたいこと: (*this).x = some thing; ref は reference の略
        return (*this).x;
    }
    A operator=(A a){ // やりたいこと: (*this) = a; 数学における代入は英語で substitution だが，計算機では値を移動することから move とする．
        (*this).x = a.x;
        return (*this);
    }
    A& operator<<(double a){ // やりたいこと: (*this) << a; これは数学にはない演算なので，わかりづらいと思うが，画面出力など情報を連続した流し込みを表現することが目標にあると思って欲しい．
        (*this).x += a; // 演習のためのただの例であり，push と名の付く関数は普通値の加算を意味しないことに注意されたい．
        return (*this);
    }
    friend A operator-(A a, A b);
};
A operator-(A a, A b) // やりたいこと: (*this) - a;
{
    A r;
    r.x = a.x - b.x;
    return r;
}
int main(){
    A a1, a2;

    a1[0] = 1;
    a2[-1] = 2;

    cout << a1[-9999] << ", " << a2[0] << "\n";

    if(a1 > a2){
        cout  << a1[1651651] << " > " << a2[0] << "\n";
    }else{
        cout << a1[0] << " < " << a2[0] << "\n";
    }

    if(a1 == a2){
        cout << a1[0] << " == " << a2[0] << "\n";
    }else{
        cout << a1[0] << " != " << a2[0] << "\n";
    }

    a1 = a1 + a2;
    cout << a1[0] << ", " << a2[0] << "\n";

    a1 = a1 - a2;
    cout << a1[0] << ", " << a2[0] << "\n";

    a1 = a2;
    cout << a1[0] << ", " << a2[0] << "\n";

    a1 = a1*2;
    cout << a1[0] << "\n";
    a1 = a1 + a2*2;
    cout << a1[0] << "\n";

    a1 << 2;
    cout << a1[0] << "\n";

    a1 << 1 << 2 << 3;
    cout << a1[0] << "\n";
    return 0;
}