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

The Fourth Dimension Space

枯葉北風(fē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;
}



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

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

評論

# 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);

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

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


  回復(fù)  更多評論   

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

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

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

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


只有注冊用戶登錄后才能發(fā)表評論。
網(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热| 香蕉久久久久久久av网站| 亚洲国产高清高潮精品美女| 亚洲人成高清| 欧美美女操人视频| 欧美一区二区视频观看视频| 久久先锋影音| 亚洲天堂成人在线视频| 欧美尤物一区| 一区二区三区国产在线| 欧美一级淫片aaaaaaa视频| 亚洲国产高潮在线观看| 亚洲午夜激情| 亚洲乱码视频| 欧美一区二区三区免费看| 在线日韩av片| 午夜日本精品| 亚洲一区999| 欧美国产精品专区| 国产精品久久久久影院色老大 | 亚洲精品永久免费| 国产精品永久免费在线| 欧美国产高潮xxxx1819| 国产亚洲亚洲| 亚洲一区二区三区精品动漫| 最新国产乱人伦偷精品免费网站 | 亚洲视频axxx| 亚洲国产精品久久人人爱蜜臀| 中文一区二区在线观看| 亚洲国产婷婷香蕉久久久久久| 亚洲一区二区三区在线观看视频| 亚洲激情午夜| 久久本道综合色狠狠五月| 亚洲专区一二三| 欧美高清视频一区二区三区在线观看| 欧美一区二区三区的| 欧美日韩一区二区三区四区五区 | 亚洲在线观看免费| 欧美激情精品久久久六区热门 | 欧美大成色www永久网站婷| 国产欧美日韩在线| 亚洲天堂第二页| 一区二区三区欧美在线观看| 免费看的黄色欧美网站| 欧美成人激情视频| 久久久国产一区二区三区| 亚洲欧洲99久久| 国产精品久久久久久模特| 亚洲精品婷婷| 99视频精品全部免费在线| 你懂的成人av| 亚洲激情在线视频| 亚洲理论电影网| 欧美激情久久久| 亚洲精华国产欧美| 亚洲人被黑人高潮完整版| 欧美凹凸一区二区三区视频| 男女精品网站| 亚洲国产福利在线| 欧美国产日韩二区| av成人老司机| 小黄鸭精品aⅴ导航网站入口 | 久久精品一区四区| 六月婷婷一区| 亚洲精品韩国| 欧美日韩综合视频| 久久精品视频播放| 狠狠色狠狠色综合| 老巨人导航500精品| 亚洲国产日本| 亚洲欧美日韩成人| 国产一区日韩欧美| 久久在线免费观看视频| 亚洲区一区二| 欧美亚洲视频| 在线观看日韩专区| 欧美日韩国产精品自在自线| 亚洲午夜精品在线| 久久久福利视频| 亚洲人成网站色ww在线| 欧美日韩性视频在线| 午夜激情久久久| 亚洲电影免费观看高清完整版在线观看| 日韩性生活视频| 国产欧美69| 欧美风情在线观看| 亚洲一区二区三区精品动漫| 欧美aa国产视频| 亚洲综合视频1区| 在线看片成人| 国产精品国产| 欧美夫妇交换俱乐部在线观看| 亚洲午夜未删减在线观看| 猛男gaygay欧美视频| 这里只有视频精品| 在线观看国产精品网站| 欧美特黄a级高清免费大片a级| 欧美中在线观看| 亚洲深夜影院| 亚洲国产日韩欧美在线99| 久久久久久一区二区| 一本色道88久久加勒比精品 | 欧美gay视频激情| 午夜精品福利一区二区蜜股av| 亚洲国产精品久久| 久久久精品一品道一区| 一区二区高清视频在线观看| 精品99一区二区| 久久婷婷国产综合尤物精品| 亚洲一区二区视频在线观看| 亚洲国产视频一区二区| 玖玖玖免费嫩草在线影院一区| 午夜日韩av| 亚洲已满18点击进入久久| 亚洲精品综合久久中文字幕| 亚洲福利电影| 极品av少妇一区二区| 国产欧美日韩麻豆91| 欧美三区不卡| 欧美三级乱码| 欧美日韩亚洲网| 欧美另类videos死尸| 欧美成人官网二区| 蜜乳av另类精品一区二区| 久久久久久久久久久成人| 久久成人综合视频| 久久精品国产精品亚洲精品| 欧美一级大片在线观看| 亚洲欧美日韩一区在线| 午夜精品久久久久久99热软件| 亚洲欧美视频一区| 欧美在线地址| 久久九九国产| 久久综合中文色婷婷| 欧美91大片| 欧美韩国一区| 欧美日韩三区四区| 欧美视频网站| 国产精品亚洲综合色区韩国| 国产日韩欧美视频在线| 国产一区深夜福利| 影音先锋亚洲一区| 亚洲精品国产精品乱码不99| 99国产精品自拍| 亚洲女ⅴideoshd黑人| 亚洲中无吗在线| 欧美有码在线观看视频| 久久免费视频网站| 欧美国产一区视频在线观看| 亚洲国产一区在线| 在线视频你懂得一区| 亚洲欧美视频在线观看视频| 久久精品亚洲乱码伦伦中文| 美女尤物久久精品| 欧美丝袜第一区| 国内久久精品视频| 亚洲精品影视在线观看| 亚洲综合视频一区| 免费在线看一区| 一区二区三区久久| 久久国产视频网| 欧美精品福利视频| 国产欧美综合在线| 91久久精品日日躁夜夜躁国产| 妖精成人www高清在线观看| 欧美亚洲在线视频| 亚洲成色www8888| 亚洲午夜在线观看视频在线| 久久青青草原一区二区| 欧美日韩综合久久| 亚洲国产激情| 羞羞答答国产精品www一本| 欧美成人一区二区| 亚洲欧美日韩高清| 欧美精品一区二区三区蜜桃 | 中文欧美日韩| 久久综合一区二区| 亚洲视频每日更新| 欧美成人精品在线| 国产一区视频在线观看免费| 妖精成人www高清在线观看| 久久综合久久综合这里只有精品 | 欧美电影电视剧在线观看| 亚洲午夜极品| 欧美日韩免费一区二区三区视频 | 亚洲综合久久久久| 亚洲国产一区二区三区a毛片| 欧美一级免费视频| 国产精品国产三级国产|