friend ostream &operator<<(ostream &out,Sum a);
friend istream &operator>>(istream &in,Sum a);
friend Sum operator^(const Sum c1,const Sum c2);
friend Sum operator~(const Sum c);
//全局<<运算符重载
ostream &operator<<(ostream &out,Sum a)
{
out << a.rel << "+" << a.vir << endl;
return out;
}
//全局>>运算符重载
istream &operator>>(istream &in,Sum a)
{
in >> a.rel >> a.vir;
return in;
}
//全局^运算符重载
Sum operator^(const Sum c1,const Sum c2)
{
Sum temp(c1.rel^c2.rel,c1.vir^c2.vir);
return temp;
}
//全局~运算符重载
Sum operator~(const Sum c)
{
Sum temp(~c.rel,~c.vir);
return temp;
}