#include <iostream>
using namespace std;
class A{
int i;
int j;
public:
A(int m = 0,int n= 0):i(m),j(n){
}
~A(){
}
A operator++()
{
++(this->i);
++(this->j);
return *this;
}
A operator++(int)
{
A x;
x.i = i;
x.j = j;
i++;
j++;
return x;
}
A operator--()
{
--(this->i);
--(this->j);
return *this;
}
A operator--(int)
{
A x;
x.i = i;
x.j = j;
(this->i)--;
(this->j)--;
return x;
}
friend A operator+(const A &a, const A &b);
friend ostream& operator<<(ostream &os,const A &a);
};
A operator+(const A &a, const A &b)
{
static A x;
x.i = a.i + b.i;
x.j = a.j + b.j;
return x;
}
ostream& operator<<(ostream &os,const A &a)
{
os << a.i << "\t" << a.j;
return os;
}
int main()
{
A a(12,13),b(22,23),c(32,33);
A d;
d = a + b;
cout << d << endl;
d = a + b + c;
cout << d << endl;
cout << a << endl;
cout << ++a << endl;
cout << a++ << endl;
cout << a << endl;
cout << a << endl;
cout << --a << endl;
cout << a-- << endl;
cout << a << endl;
return 0;
}
using namespace std;
class A{
int i;
int j;
public:
A(int m = 0,int n= 0):i(m),j(n){
}
~A(){
}
A operator++()
{
++(this->i);
++(this->j);
return *this;
}
A operator++(int)
{
A x;
x.i = i;
x.j = j;
i++;
j++;
return x;
}
A operator--()
{
--(this->i);
--(this->j);
return *this;
}
A operator--(int)
{
A x;
x.i = i;
x.j = j;
(this->i)--;
(this->j)--;
return x;
}
friend A operator+(const A &a, const A &b);
friend ostream& operator<<(ostream &os,const A &a);
};
A operator+(const A &a, const A &b)
{
static A x;
x.i = a.i + b.i;
x.j = a.j + b.j;
return x;
}
ostream& operator<<(ostream &os,const A &a)
{
os << a.i << "\t" << a.j;
return os;
}
int main()
{
A a(12,13),b(22,23),c(32,33);
A d;
d = a + b;
cout << d << endl;
d = a + b + c;
cout << d << endl;
cout << a << endl;
cout << ++a << endl;
cout << a++ << endl;
cout << a << endl;
cout << a << endl;
cout << --a << endl;
cout << a-- << endl;
cout << a << endl;
return 0;
}