标题:c++代码这种报错怎么弄
取消只看楼主
domore
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2019-7-25
结帖率:60%
 问题点数:0 回复次数:0 
c++代码这种报错怎么弄
为什么会出现这种报错  怎么弄

#include<iostream>
using namespace std;
class Complex
    {public:
        Complex(){real=0;imag=0;}
        Complex(double r){real=r;imag=0;}
        Complex(double r,double i){real=r;imag=i;}
        friend Complex operator+(Complex c1,Complex c2);
        void display();
     private:
         double real;
         double imag;
    };
Complex operator+(Complex c1,Complex c2)
    {return Complex(c1.real+c2.real,c1.imag+c2.imag);
    }
void Complex::display()
    {cout<<"("<<real<<","<<imag<<"i)"<<endl;
    }
int main()
    {Complex c1(3,4),c2(5,-10),c3;
     c3=c1+2.5;
     c3.display();
     return 0;
    }
搜索更多相关主题的帖子: double 报错 real Complex 代码 
2019-09-19 22:02



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-496917-1-1.html




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

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