| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 400 人关注过本帖
标题:INTERNAL COMPILER ERROR 怎么改
只看楼主 加入收藏
糊涂无罪
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:37
专家分:161
注 册:2012-5-28
结帖率:77.78%
收藏
已结贴  问题点数:5 回复次数:1 
INTERNAL COMPILER ERROR 怎么改

#include <iostream>
using namespace std;

class complex{
public:
    complex(double r=0.0,double i=0.0){
    real=r;
    image=i;}
   
friend complex operator+( const complex &c1,const complex &c2);
private:
    double real;
    double image;
};
complex operator+( const complex &c1,const complex &c2);{
    real=c1.real+c2.real;
    image=c1.image+c2.image;
    return complex(real,image);}
int main(){
     complex c3,c4,c5;
c3(1.0,2.0);
c4(2.0,3.0);
cout<<"c3="<<c3<<endl;
cout<<"c4="<<c4<<endl;
c5=c3+c4;
cout<<"c3+c4="<<c5<<endl;
c3(1.0);
c4(2.0,3.0);
cout<<"c3="<<c3<<endl;
cout<<"c4="<<c4<<endl;
c5=c3+c4;
cout<<"c3+c4="<<c5<<endl;
c3(1.0,2.0);
c4(2.0);
cout<<"c3="<<c3<<endl;
cout<<"c4="<<c4<<endl;
c5=c3+c4;
cout<<"c3+c4="<<c5<<endl;
return 0;}
搜索更多相关主题的帖子: double private complex include 
2012-06-06 10:26
hellovfp
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:禁止访问
威 望:30
帖 子:2976
专家分:7697
注 册:2009-7-21
收藏
得分:5 
#include <iostream>
using namespace std;

class complex{
public:
    complex(double r=0.0,double i=0.0){
        real=r;
        image=i;}
    complex operator += (const complex &rhs)
    {
        real += rhs.real;
        image += rhs.image;
        return *this;
    }
    friend ostream& operator << (ostream &os, const complex &rhs)
    {
        cout << rhs.real << ":" << rhs.image << endl;
        return os;
    }
private:
    double real;
    double image;
};

complex operator+( const complex &c1,const complex &c2){
    complex temp(c1);
    return temp += c2;
}

int main()
{
   
    complex c5;
    complex c3(1.0,2.0);
    complex c4(2.0,3.0);

    c5 = c3 + c4;
    cout<<"c3="<<c3<<endl;
    cout<<"c4="<<c4<<endl;
    cout << "c5=" << c5 << endl;

    return 0;
}

我们都在路上。。。。。
2012-06-06 12:24
快速回复:INTERNAL COMPILER ERROR 怎么改
数据加载中...
 
   



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

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