#include <iostream>
using namespace std;

class three_d {
    int x, y, z;
public:
    three_d(int a, int b, int c) {x=a; y=b, z=c; }
    three_d operator+(three_d op2);
    friend ostream &operator<<(ostream &stream, three_d &obj);
    friend ostream &operator<<(ostream &stream, const three_d &obj);
    operator int() {cout << "converting to int"<< endl; return x*y*z;}
};
ostream &operator<< (ostream &stream, three_d &obj)
{
    stream << "(non-const) ";
    stream << obj.x << ", ";
    stream << obj.y << ", ";
    stream << obj.z << endl;
    return stream;
}
ostream &operator<< (ostream &stream, const three_d &obj)
{
    stream << "(const) ";
    stream << obj.x << ", ";
    stream << obj.y << ", ";
    stream << obj.z << endl;
    return stream;
}
three_d three_d::operator+ (three_d op2)
{
    cout << "adding" << endl;
    x+=op2.x;
    y+=op2.y; 
    z+=op2.z; 
    return *this;
}

int main()
{
    three_d a(1, 2, 3), b(2, 3, 4);
    cout << a << b;
    cout << "b+100" << endl;
    cout << b+100 << endl; //31 line
    cout << "a+b" << endl;
    cout << a+b << endl; // 32
    return 0;
}
