| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1220 人关注过本帖
标题:为什么我编的复数类不能执行除法运算了 ,能编译 ,不能生成
只看楼主 加入收藏
q236763612
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-10-22
收藏
 问题点数:0 回复次数:0 
为什么我编的复数类不能执行除法运算了 ,能编译 ,不能生成
#include<iostream>
#include<cassert>
using namespace std;
class Complex
{
private:
    int Real ;
    int Image;
public:
Complex(int r=0, int i=0)
:Real(r),Image(i)
{}
~Complex()



  Real=a.Real ;
  Image=a.Image ;
}
Complex& operator=(const Complex& a)
{
    assert(this!=&a);
   Real=a.Real;
  Image=a.Image ;
  return *this;
}
void print()
{
    cout<<Real<<"+"<<Image<<"i"<<endl;
}
friend Complex Add(const Complex& a, const Complex& b);
friend Complex Div(const Complex& a, const Complex& b);
};
Complex Add( const Complex& a, const Complex& b)
{
    return Complex (a.Real +b.Real ,a.Image+b.Image );

}
Complex Div ( const Complex& a , const Complex& b)
{
    assert( b.Real *b.Image !=0);
  return  Complex ( (a.Real *b.Real +a.Image*b.Image)/(b.Real*b.Real  +b.Image*b.Image), (a.Image *b.Real -a.Real *b.Image)/(b.Real*b.Real  +b.Image*b.Image ));
}
int  main ()
{
    Complex a,b,c;
  a.SetComplex ();
  b.SetComplex ();
  c=Div (a,b);
  c.print();
}
搜索更多相关主题的帖子: 除法 运算 编译 
2008-11-11 11:14
快速回复:为什么我编的复数类不能执行除法运算了 ,能编译 ,不能生成
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015750 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved