爱问知识人 爱问教育 医院库

这个C 程序有什么问题?

首页

这个C 程序有什么问题?

#include<iostream>usingnamespacestd;classComplex{ (){real=0;imag=0;Complex(doubler,doublei){real=r,imag=i};doubleget_real();doubleget_imag();voiddisplay(); };doubleComplex::get_real(){returnreal;}doubleComplex::get_imag(){returnimag;}voidComplex::display(){cout<<"("<<real<<","<<imag<<"i)"<<endl;}Complexoperator+(Complexc1,Complexc2){returnComplex( t_real()+ t_real, ag()+ t_imag());}intmain(){Complexc1(3,4),c2(5,-10),c3;c3=c1+c2;cout<<"c3=";c3.display();return0;}我在visualC++6上运行,有三个错误,1,binary'operator+'hastoomanyparameters;2,'+':errorinfunctiondeclaration;skippingfunctionbody;3,unexpectedendoffilefound。但我觉得没有错误,到底是什么问题?谢谢!!

提交回答
好评回答
  • 2008-05-11 01:23:41
      我把你的程序调好了,把调过的代码贴在这里:对于你提问的那三个错误,你仔细对照下面的代码就知道怎么改了:)#includeusingnamespacestd;classComplex{ (){real=0;imag=0;}Complex(doubler,doublei){real=r;imag=i;}doubleget_real();doubleget_imag();voiddisplay(); };doubleComplex::get_real(){returnreal;}doubleComplex::get_imag(){returnimag;}voidComplex::display(){cout<<"("<  display();return0;}。

    d***

    2008-05-11 01:23:41

类似问题

换一换
  • C/C++ 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 173-192
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):