#include <iostream>
using namespace std;
class A
{
friend A& operator++ (A& a);
friend A operator++ (A& a, int);
public:
operator int() { return a_; }
A& operator = (int a) { a_ = a; return *this; }
private:
int a_;
};
A& operator++ (A& a)
{
++a.a_;
return a;
}
A operator++ (A& a, int)
{
A temp = a;
++a.a_;
return temp;
}
int main()
{
A a1;
a1 = 3;
cout << "initial a1=" << a1 << endl;
A a2 = ++a1;
cout << "pre, a1=" << a1 << ", a2=" << a2 << endl;
a2 = a1++;
cout << "post, a1=" << a1 << ", a2=" << a2 << endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgQQp7CiAgICAgICAgZnJpZW5kIEEmIG9wZXJhdG9yKysgKEEmIGEpOwogICAgICAgIGZyaWVuZCBBIG9wZXJhdG9yKysgKEEmIGEsIGludCk7CnB1YmxpYzoKICAgICAgICBvcGVyYXRvciBpbnQoKSB7IHJldHVybiBhXzsgfQogICAgICAgIEEmIG9wZXJhdG9yID0gKGludCBhKSB7IGFfID0gYTsgcmV0dXJuICp0aGlzOyB9CnByaXZhdGU6CiAgICAgICAgaW50IGFfOwp9OwoKQSYgb3BlcmF0b3IrKyAoQSYgYSkKewogICAgICAgICsrYS5hXzsKICAgICAgICByZXR1cm4gYTsKfQoKQSBvcGVyYXRvcisrIChBJiBhLCBpbnQpCnsKICAgICAgICBBIHRlbXAgPSBhOwogICAgICAgICsrYS5hXzsKICAgICAgICByZXR1cm4gdGVtcDsKfQoKaW50IG1haW4oKQp7CiAgICAgICAgQSBhMTsKICAgICAgICBhMSA9IDM7CiAgICAgICAgY291dCA8PCAiaW5pdGlhbCBhMT0iIDw8IGExIDw8IGVuZGw7CiAgICAgICAgQSBhMiA9ICsrYTE7CiAgICAgICAgY291dCA8PCAicHJlLCBhMT0iIDw8IGExIDw8ICIsIGEyPSIgPDwgYTIgPDwgZW5kbDsKICAgICAgICBhMiA9IGExKys7CiAgICAgICAgY291dCA8PCAicG9zdCwgYTE9IiA8PCBhMSA8PCAiLCBhMj0iIDw8IGEyIDw8IGVuZGw7Cn0KCg==