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

The Fourth Dimension Space

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

復(fù)數(shù)類(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;
}



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

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

評(píng)論

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

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

很明顯返回丟失了 &
成了另外一個(gè)函數(shù)的友元聲明了

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


  回復(fù)  更多評(píng)論   

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

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

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

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


只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   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>
            欧美日韩成人免费| 国产精品99久久不卡二区| 久久精品一区二区三区中文字幕| 亚洲精品久久久久| 欧美韩日一区二区| 亚洲国产日本| 一本色道久久88精品综合| a91a精品视频在线观看| 中文一区在线| 久久精品国产综合| 欧美sm视频| 国产精品久久看| 国产一区二区三区成人欧美日韩在线观看 | 亚洲久久一区二区| 亚洲私人影吧| 久久精品一区二区国产| 久久久久久一区| 欧美激情在线狂野欧美精品| 一区二区三区久久网| 欧美专区在线观看| 欧美伦理视频网站| 好吊妞这里只有精品| 日韩午夜高潮| 久久久久综合网| 91久久精品美女| 性色av一区二区怡红| 欧美大色视频| 国产热re99久久6国产精品| 91久久精品久久国产性色也91| 亚洲婷婷综合久久一本伊一区| 久久国产日韩欧美| 亚洲精品一区二区三区樱花| 午夜精品亚洲一区二区三区嫩草| 久久免费国产| 国产欧美午夜| 一区二区高清在线观看| 米奇777在线欧美播放| 亚洲精品中文在线| 另类尿喷潮videofree| 国产欧美短视频| 在线综合亚洲欧美在线视频| 久久久午夜精品| 亚洲新中文字幕| 欧美日韩岛国| 亚洲国产一区二区三区高清| 久久大逼视频| 宅男噜噜噜66一区二区| 欧美精品xxxxbbbb| 久久久久久综合| 亚洲影视中文字幕| 亚洲激情成人网| 免费亚洲电影在线| 亚洲国产欧美一区| 欧美www视频在线观看| 久久精品国产69国产精品亚洲 | 亚洲一区二区三区精品在线| 欧美激情一区二区三区不卡| 在线观看视频一区二区欧美日韩| 久久xxxx| 欧美一区影院| 国产一区二区三区日韩| 久久aⅴ国产欧美74aaa| 先锋影音国产一区| 国产一本一道久久香蕉| 久久久久一区| 久久不射网站| 在线观看av不卡| 欧美福利视频网站| 欧美电影打屁股sp| 99精品热视频| 在线视频欧美日韩精品| 国产精品嫩草久久久久| 亚洲一区二区三区精品在线| 一区二区免费在线播放| 欧美三区视频| 欧美一区中文字幕| 香蕉亚洲视频| 亚洲国产精品久久久久婷婷老年 | 欧美成人有码| 欧美精品久久久久久久免费观看| 一区二区三区四区精品| 亚洲美女av黄| 国产一区二区三区无遮挡| 女女同性女同一区二区三区91| 蜜月aⅴ免费一区二区三区| 一区二区三区视频在线播放| 亚洲欧美激情视频| 亚洲第一中文字幕在线观看| 亚洲精品一区二区三区蜜桃久| 国产精品永久入口久久久| 欧美777四色影视在线| 免费看黄裸体一级大秀欧美| 在线视频欧美一区| 久久se精品一区二区| 最新成人av在线| 一区二区三区免费网站| 尤物九九久久国产精品的特点| 亚洲精品综合在线| 狠狠色丁香久久综合频道| 亚洲精品在线免费| 尤物在线精品| 午夜国产精品影院在线观看 | 久久久久国产一区二区| 欧美精品二区三区四区免费看视频| 亚洲天堂av在线免费| 国产精品久久久久7777婷婷| 亚洲午夜日本在线观看| 欧美专区日韩视频| 亚洲一区二区三区高清不卡| 久久综合导航| 久久国产手机看片| 欧美日韩精品一区二区| 麻豆成人小视频| 欧美丝袜第一区| 亚洲电影第三页| 国产一区二区日韩精品欧美精品| 日韩视频在线一区二区| 亚洲福利专区| 欧美一区二区三区喷汁尤物| 在线视频免费在线观看一区二区| 看欧美日韩国产| 久久精品亚洲一区| 欧美视频精品一区| 欧美成人免费大片| 国产视频一区在线| 亚洲欧美美女| 亚洲免费人成在线视频观看| 欧美电影免费观看高清| 久久亚洲不卡| 国产偷久久久精品专区| 亚洲综合色婷婷| 欧美一区二区| 国产精品久久久久久久久免费| 亚洲国产一区二区三区在线播 | 91久久综合| 蜜臀久久久99精品久久久久久 | 亚洲自拍另类| 欧美日韩你懂的| 99国产精品久久久久久久成人热| 亚洲精品日韩精品| 免费久久精品视频| 亚洲国产婷婷香蕉久久久久久| 亚洲日韩中文字幕在线播放| 欧美大片专区| 一区二区三区久久网| 午夜视频久久久| 国产日韩欧美成人| 久久国产精品一区二区三区四区 | 国产无遮挡一区二区三区毛片日本| 亚洲一区二区三区欧美| 性做久久久久久免费观看欧美| 国产精品另类一区| 欧美一级久久久久久久大片| 久久伊人一区二区| 亚洲精品极品| 国产精品久久久久久福利一牛影视 | 影音先锋亚洲精品| 玖玖玖免费嫩草在线影院一区| 亚洲激情不卡| 欧美一区激情| 好吊妞这里只有精品| 亚洲综合首页| 国产精品国产精品| 午夜宅男久久久| 亚洲成人直播| 亚洲欧美中日韩| 亚洲第一成人在线| 欧美日精品一区视频| 欧美一区二区成人6969| 欧美国产日本韩| 午夜精品免费| 亚洲黄一区二区| 国产精品三区www17con| 久久亚洲精品视频| 亚洲一级网站| 亚洲福利视频网| 欧美一区二区精品久久911| 亚洲国产精品成人久久综合一区| 国产精品第13页| 六月婷婷久久| 香蕉免费一区二区三区在线观看| 亚洲人www| 久久久久久亚洲精品杨幂换脸| 亚洲精品国产精品国自产在线| 国产精品久久久久久久久免费樱桃 | 国产亚洲欧美另类一区二区三区| 女同一区二区| 久久国产手机看片| 一级日韩一区在线观看| 女仆av观看一区| 久久国产精品99国产| 亚洲最新合集| 亚洲激情在线视频| 国产午夜精品久久久久久免费视| 欧美日韩国产页| 噜噜噜在线观看免费视频日韩| 欧美在线一区二区| 亚洲欧美日韩系列| 一区二区三区国产精品| 亚洲欧洲日本国产|