close
#include
using namespace std;
class Funtion
{
private: int real;
   int nul;
public:
 void show()
 {
  cout< }
 Funtion(int r, int n)
 {
  real=r;
  nul=n;
 }
 Funtion operator+(Funtion X)
 {
  Funtion temp(0,0);
  temp.real=this->real+X.real;
        temp.nul=this->nul+X.nul;
  return temp;
 }
 Funtion operator-(Funtion X)
 {
  Funtion temp(0,0);
  temp.real=this->real-X.real;
        temp.nul=this->nul-X.nul;
  return temp;
 }
 Funtion operator*(Funtion X)
 {
  Funtion temp(0,0);
  temp.real=this->real*X.real-temp.nul*X.nul;
        temp.nul=this->nul*X.real+temp.real*X.nul;
  return temp;
 }
 
};
 void main(void)
 {
  Funtion x(4,5),y(3,2),r(0,0),s(0,0),t(0,0);
  r=x*y;
  s=x+y;
  t=x-y;
  cout<<"x+y="<   r.show();
  cout<<"x-y="<   s.show();
  cout<<"x*y="<   t.show();
 }
arrow
arrow
    全站熱搜

    mitia 發表在 痞客邦 留言(0) 人氣()