青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

The Fourth Dimension Space

枯葉北風寒,忽然年以殘,念往昔,語默心酸。二十光陰無一物,韶光賤,寐難安; 不畏形影單,道途阻且慢,哪曲折,如渡飛湍。斬浪劈波酬壯志,同把酒,共言歡! -如夢令

復數類(Comlex Class)

#include<iostream>
#include
<cmath>
using namespace std;


/////////////////////////////Complex Class///////////////////////////////////////
class Complex
{
private:
    
//double real;
    
//double image;
    
//void show();
public:
    
void show();
    
double real;
    
double image;
    Complex()
{real=0;image=0;}
    
~Complex(){}
    Complex(
double a,double b){real=a;image=b;}
    
double Getreal(){return real;}
    
double Getimage(){return image;}

    
double abs(){return sqrt(real*real+image*image);}

    Complex 
operator +(Complex &other);
    Complex 
operator +(const double &other);
    Complex 
operator +(const int &other);

    Complex 
operator -(Complex &other);
    Complex 
operator -(const double &other);
    Complex 
operator -(const int &other);

    Complex 
operator *(Complex &other);
    Complex 
operator *(const double &other);
    Complex 
operator *(const int &other);



    Complex 
operator /(Complex &other);
    Complex 
operator /(const double &other);
    Complex 
operator /(const int &other);

    
void operator +=(Complex &other);
    
void operator +=(const double &other);
    
void operator +=(const int &other);

    
void operator -=(Complex &other);
    
void operator -=(const double &other);
    
void operator -=(const int &other);

    
void operator *=(Complex &other);
    
void operator *=(const double &other);
    
void operator *=(const int &other);

    
void operator /=(Complex &other);
    
void operator /=(const double &other);
    
void operator /=(const int &other);

    Complex 
operator =(Complex &other);
    Complex 
operator =(const double &other);
    Complex 
operator =(const int &other);

    
bool operator ==(Complex &other);
    
bool operator ==(const double &other);
    
bool operator ==(const int &other);

    friend iostream 
operator<<(iostream &os,Complex &other);
    friend iostream 
operator>>(iostream &is,Complex &other);





}
;


void Complex::show()
{

    
if(real>0&&image<0)
        printf(
"%g%gj",real,image);
    
else if(real>0&&image>0)
        printf(
"%g+%gj",real,image);
    
else if(real<0&&image>0)
        printf(
"%g+%gj",real,image);
    
else if(real<0&&image<0)
        printf(
"%g%gj",real,image);
    
else if(real==0&&image!=0)
        printf(
"%gj",image);
    
else if(real!=0&&image==0)
        printf(
"%g",real);
    
else 
        printf(
"0");
}


Complex Complex::
operator+(Complex &other)
{
    Complex temp;
    temp.real
=real+other.real;
    temp.image
=image+other.image;
    
return temp;
}


Complex Complex::
operator +(const double &other)
{

    Complex temp;
    temp.real
=real+other;
    temp.image
=image;
    
return temp;
}


Complex Complex::
operator +(const int &other)
{
    Complex temp;
    temp.real
=real+(double)other;
    temp.image
=image;
    
return temp;
}



Complex Complex::
operator-(Complex &other)
{
    
    Complex temp;
    temp.real
=real-other.real;
    temp.image
=image-other.image;
    
return temp;
}


Complex Complex::
operator -(const double &other)
{
    
    Complex temp;
    temp.real
=real-(double)other;
    temp.image
=image;
    
return temp;
}


Complex Complex::
operator -(const int &other)
{
    
    Complex temp;
    temp.real
=real-(double)other;
    temp.image
=image;
    
return temp;
}

Complex Complex::
operator*(Complex &other)
{
    Complex temp;
    temp.real
=(real*other.real-image*other.image);
    temp.image
=(image*other.real+real*other.image);
    
return temp;
    

}


Complex Complex::
operator *(const double &other)
{
    Complex temp;
    temp.real
=real*other;
    temp.image
=image*other;
    
return temp;
}


Complex Complex::
operator *(const int &other)
{
    Complex temp;
    temp.real
=real*(double)other;
    temp.image
=image*(double)other;
    
return temp;
}


Complex Complex::
operator/(Complex &other)
{

    Complex temp;
    temp.real
=((real*other.real)+(image*other.image))/(other.real*other.real+other.image*other.image);
    temp.image
=((image*other.real)-(real*other.image))/(other.real*other.real+other.image*other.image);
    
return temp;

}


Complex Complex::
operator /(const double &other)
{
    Complex temp;
    temp.real
=real/other;
    temp.image
=image/other;
    
return temp;

}


Complex Complex::
operator /(const int &other)
{
    Complex temp;
    temp.real
=real/(double)other;
    temp.image
=image/(double)other;
    
return temp;
}





void Complex::operator+=(Complex &other)
{
    
this->real+=other.real;
    
this->image+=other.image;
}


void Complex::operator +=(const double &other)
{
    
    
this->real+=other;
}


void Complex::operator +=(const &other)
{
    
this->real+=(double)other;
}






void Complex::operator-=(Complex &other)
{
    
this->real-=other.real;
    
this->image-=other.image;
}


void Complex::operator -=(const double &other)
{
    
    
this->real-=other;
}


void Complex::operator -=(const int &other)
{
    
this->real-=(double)other;
}




void Complex::operator*=(Complex &other)
{
    
this->real=(real*other.real-image*other.image);
    
this->image=(image*other.real+real*other.image);;
}


void Complex::operator *=(const double &other)
{
    
    
this->real=real*other;
    
this->image=image*other;
}


void Complex::operator *=(const int &other)
{
    
this->real=real*(double)other;
    
this->image=image*(double)other;
}



void Complex::operator/=(Complex &other)
{
    
this->real=((real*other.real)+(image*other.image))/(other.real*other.real+other.image*other.image);
    
this->image=((image*other.real)-(real*other.image))/(other.real*other.real+other.image*other.image);
}


void Complex::operator /=(const double &other)
{
    
    
this->real=real/other;
    
this->image=image/other;
}


void Complex::operator /=(const int &other)
{
    
this->real=real/(double)other;
    
this->image=image/(double)other;
}


Complex Complex::
operator= (Complex &other)
{

    
this->real=other.real;
    
this->image=other.image;
    
return *this;

}

Complex Complex::
operator =(const double &other)
{
    
this->real=other;
    
this->image=image;
    
return *this;


}

Complex Complex::
operator =(const int &other)
{
    
this->real=(double)other;
    
this->image=image;
    
return *this;
}



bool Complex::operator ==(Complex &other)
{

    
if(this->real=other.real&&this->image==other.image)
        
return true;
    
else return false;
}

bool Complex::operator ==(const double &other)
{

    
if(this->real==other&&this->image==0)
        
return true;
    
else 
        
return false;
}

bool Complex::operator ==(const int &other)
{
    
if(this->real==(double)other&&this->image==0)
        
return true;
    
else 
        
return false;
}


ostream
& operator<<(ostream &cout,Complex &other)
{
    other.show();
    
return cout;
}


istream
& operator>>(istream &cin,Complex &other)
{
    cin
>>other.real;
    cin
>>other.image;
    
return cin;
}

/////////////////////////////END_COMPLEX_CLASS///////////////////////////////















int main()
{
    Complex test1(
10,6);
    Complex test2(
5,3);
    cout
<<test1*test2<<endl;
    cout
<<test1+test2<<endl;
    cout
<<test1/test2<<endl;
    cout
<<test1-test2<<endl;
    
return 0;
}



不知道是人品問題還是其他什么因素,當我把real和image放在私有成員里面時編譯居然會報錯???我已經將>>和<<重載為友元函數了丫?
我試了下網上和我寫的差不多的程序,結果是他的能過我的 就是不行,而出問題的<<,>>部分居然還是一樣的。我...無語了...究竟是怎么回事?

posted on 2009-05-29 20:46 abilitytao 閱讀(1907) 評論(3)  編輯 收藏 引用

評論

# re: 復數類(Comlex Class) 2009-05-29 21:09 Pterosaur

friend iostream operator<<(iostream &os,Complex &other);
friend iostream operator>>(iostream &is,Complex &other);

很明顯返回丟失了 &
成了另外一個函數的友元聲明了

改成這樣:
friend iostream& operator<<(iostream &os,Complex &other);
friend iostream& operator>>(iostream &is,Complex &other);


  回復  更多評論   

# re: 復數類(Comlex Class) 2009-05-29 21:38 zhaoyg

VC6下,我記得,
<iostream.h> 且去掉using編譯
這樣才能使用友元  回復  更多評論   

# re: 復數類(Comlex Class) 2009-05-29 21:50 abilitytao

@zhaoyg
按照你的方法 終于過編譯了 謝謝:-)  回復  更多評論   


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            国产欧美精品日韩| 国产嫩草影院久久久久| 小黄鸭精品aⅴ导航网站入口| 欧美怡红院视频| 亚洲视频一区二区| 免费高清在线视频一区·| 久久精品免费| 欧美视频在线免费| 亚洲人成啪啪网站| 精品51国产黑色丝袜高跟鞋| 亚洲一区二区动漫| 亚洲图片在区色| 欧美激情一区二区三区四区| 久久久久九九九九| 国产性天天综合网| 亚洲一区精品视频| 亚洲欧美成人网| 欧美日韩国产成人精品| 亚洲激情第一页| 亚洲精品日韩一| 欧美成人午夜激情在线| 欧美激情1区2区3区| 亚洲国产精品高清久久久| 久久久久久亚洲精品杨幂换脸 | 久久激情网站| 国产精品永久在线| 欧美一二三区精品| 国产日韩一级二级三级| 国产亚洲精品综合一区91| 国产亚洲精品v| 国产精品丝袜久久久久久app| 免费在线一区二区| 久久不见久久见免费视频1| 亚洲免费在线看| 亚洲色诱最新| 亚洲欧美清纯在线制服| 亚洲欧美日韩中文播放| 国产日韩欧美黄色| 男男成人高潮片免费网站| 国内激情久久| 开元免费观看欧美电视剧网站| 免费高清在线一区| 亚洲美女网站| 欧美日韩国产成人| 亚洲一区二区成人在线观看| 久久久久久久999精品视频| 韩国女主播一区二区三区| 久久综合九色99| 亚洲精品国产精品国自产观看浪潮| 在线亚洲观看| 国产在线国偷精品产拍免费yy| 久久免费的精品国产v∧| 亚洲国产精品国自产拍av秋霞| 在线中文字幕一区| 国产一区二区三区高清播放| 免费久久精品视频| 亚洲一区二区欧美| 欧美成人蜜桃| 午夜日韩在线观看| 亚洲激情啪啪| 国产精品一区二区男女羞羞无遮挡 | 欧美成人激情视频| 亚洲视频电影图片偷拍一区| 国产日本欧美一区二区| 欧美激情一区二区三区在线视频观看 | 久久欧美中文字幕| 在线一区欧美| 欧美国产在线电影| 欧美在线短视频| 亚洲美女视频| 激情久久久久久| 国产精品v亚洲精品v日韩精品| 久久久午夜精品| 在线性视频日韩欧美| 欧美成人在线网站| 欧美专区日韩专区| 99re6这里只有精品视频在线观看| 国产日产欧产精品推荐色| 欧美精品激情blacked18| 久久9热精品视频| 亚洲欧美日韩精品久久奇米色影视| 亚洲欧洲精品一区二区| 国产精品极品美女粉嫩高清在线 | 亚洲第一区色| 久久av一区二区三区| 欧美影院在线播放| 国产欧美日韩一级| 久久av二区| 国产一区二区三区四区五区美女| 亚洲视频中文| 亚洲精品小视频在线观看| 久热精品视频在线观看一区| 午夜精品理论片| av成人免费在线观看| 亚洲精品综合精品自拍| 黑人巨大精品欧美黑白配亚洲| 国产精品久久毛片a| 欧美日韩在线看| 欧美日韩成人免费| 欧美精品一区二区久久婷婷| 欧美a级片网站| 麻豆精品精品国产自在97香蕉| 久久国产直播| 久久久久久网址| 久久手机精品视频| 久久综合中文| 免费看亚洲片| 欧美激情综合在线| 欧美日本高清| 欧美视频在线播放| 国产精品久久久久9999高清| 国产精品国产三级国产普通话蜜臀 | 欧美视频精品在线观看| 欧美日韩中国免费专区在线看| 欧美精品久久99久久在免费线| 免费观看成人鲁鲁鲁鲁鲁视频| 蜜臀av一级做a爰片久久| 欧美国产精品一区| 欧美日韩一区二区在线| 欧美视频四区| 国产日产欧产精品推荐色| 国内伊人久久久久久网站视频| 狠狠久久综合婷婷不卡| 亚洲高清激情| 一区二区三区免费在线观看| 午夜精品福利一区二区蜜股av| 欧美一区二区免费| 久热精品视频在线观看| 欧美韩国一区| 一区二区三区蜜桃网| 小黄鸭精品aⅴ导航网站入口| 久久国产精品久久精品国产| 蜜臀av国产精品久久久久| 欧美日韩免费视频| 国产精品伊人日日| 亚洲国产精品黑人久久久| 日韩亚洲欧美成人| 欧美一区二区三区另类| 久久综合久久久久88| 欧美激情va永久在线播放| 久久精品噜噜噜成人av农村| 一区免费在线| 一区二区三区视频在线| 国产精品乱码一区二区三区| 亚洲欧美资源在线| 欧美+日本+国产+在线a∨观看| 国产精品欧美日韩久久| 欧美呦呦网站| 亚洲欧洲一区二区在线播放| 中文久久乱码一区二区| 国产日韩精品久久| 欧美激情国产日韩精品一区18| 亚洲激情网站免费观看| 亚洲大胆在线| 亚洲欧美日韩国产综合精品二区 | 亚洲欧美日韩综合| 欧美成在线视频| 亚洲在线播放| 欧美日韩国产精品成人| 国产中文一区二区| 中日韩视频在线观看| 欧美freesex8一10精品| 亚洲一区亚洲二区| 欧美精品综合| 亚洲国产小视频在线观看| 久久成人18免费网站| 9l国产精品久久久久麻豆| 久久人人爽人人爽| 国产日韩欧美一区二区| 国产精品99久久久久久久vr| 美女国产一区| 欧美一级理论性理论a| 欧美性色综合| 日韩午夜在线观看视频| 女人色偷偷aa久久天堂| 先锋影音网一区二区| 国产精品毛片va一区二区三区 | 久久精品国产成人| 亚洲性感美女99在线| 欧美日韩成人| 99热在这里有精品免费| 欧美国产日韩xxxxx| 久久午夜电影网| 精久久久久久| 老色鬼精品视频在线观看播放| 午夜亚洲视频| 国产午夜精品一区二区三区欧美| 亚洲欧美日韩中文播放| 亚洲天堂激情| 国产精品亚发布| 欧美一区二区三区另类| 亚洲欧美国产高清va在线播| 欧美亚洲成人网| 亚洲一区二区三区在线看| 99这里有精品| 国产精品美女久久久| 欧美在线高清| 久久久久国产成人精品亚洲午夜| 一区二区三区我不卡| 欧美高清免费|