#include <iostream>
using namespace std;
struct A
{
int x;
public:
A() : x(0) {cout<<"Конструктор 1 this = "<<this<<endl;}
A(int a) : x(a) {cout<<"Конструктор 2 this = "<<this<<endl;}
~A() {cout<<"Деструктор this = "<<this<<endl;}
A(const A &rhs)
{
cout<<"Конструктор копирования this = "<<this;
cout<<" &rhs = "<<&rhs<<endl;
x=rhs.x;
}
A & operator = (const A &rhs)
{
cout<<"operator = this = "<<this;
cout<<" &rhs = "<<&rhs<<endl;
if(this != &rhs) x=rhs.x;
return *this;
}
/*A operator + (const A &rhs)
{
cout<<"operator + this = "<<this;
cout<<" &rhs = "<<&rhs<<endl;
return A(x+rhs.x);
}
A operator + (int rhs)
{
cout<<"???? operator + this = "<<endl;
return A(x+rhs);
}*/
operator int() const
{
cout<<"operator int() "<<this<<endl;
return x;
}
bool operator == (const A &rhs)
{
cout<<"operator == this = "<<this;
cout<<" &rhs = "<<&rhs<<endl;
if (x==rhs.x) return true;
return false;
}
int func_1() const {return x;}
};
A operator+ (int k, const A &r)
{
cout<<"!!!!! operator + &r = "<<&r<<endl;
return A(k+r.x);
}
int main()
{
A a;
cout<<"x = "<<a.func_1()<<endl;
A b;
cout<<"x = "<<b.func_1()<<endl;
A c;
c=2+a;
return 0;
}