[/code]# include
using namespace std;
The class person
{
Friend void test01 ();
Friend void test02 ();
Friend ostream& Operator<(ostream& Cout, person p);
Friend person& Operator - (person& P);
Friend person operator - (person& P, int);
Private:
Int m_age;
Public:
The person (s)
{
M_age=0;
}
The person (int a)
{
M_age=a;
}
};
//overload & lt;
{
Cout & lt;
}
//overloaded front descending
Person& Operator - (person& P)
{
- p. _age;
return p;
}
Diminishing/rear/overloaded
The person operator - (person& P, int)
{
The person temp=p. _age;
P. _age -;
return temp;
}
Void test01 ()
{
Person p;
Cout & lt; <- p & lt;
Void test02 ()
{
Person p;
Cout & lt; Cout & lt; }
Int main ()
{
Test01 ();
Test02 ();
system("pause");
return 0;
}
Why left shift operator overloading ostream& Operator<(ostream& Cout, person p)
I used a reference person& parameter person p; P, diminishing the front cout & lt; <- p & lt;