注册 登录
编程论坛 C++教室

帮忙找一下程序的错误

sunshanjin 发布于 2012-03-17 12:48, 399 次点击
     //关于复数的重载
#include<iostream>
using namespace std;
int Add(int a,int b);
double Add(double f1,double f2);
struct complex
{
    double real;
    double imag;
};
complex Add(complex c1,complex c2);

void main()
{
    int a,b;
    cin>>a>>b;
    cout<<a<<'+'<<b<<"="<<Add(a,b)<<endl;
    double f1,f2;
    cin>>f1>>f2;
    cout<<f1<<'+'<<f2<<"="<<Add(f1,f2)<<endl;
    complex c1,c2,c;
    *cin>>c1.real<<c1.imag<<c2.real<<c2.imag;
    *cout<<c.real<<'+'<<c.imag<<"="<<Add(c1,c2)<<endl;
}
int Add(int a,int b)
{
    return a+b;
}
double Add(double a,double b)
{
    return a+b;
}
complex Add(complex c1,complex c2)
{
    complex c;
    c.real=c1.real+c2.real;
    c.imag=c1.imag+c2.imag;
    return c;
}
请高手解决一下错误,错误红色标出,谢谢
1 回复
#2
nicum2012-03-17 20:34
cin>>c1.real<<c1.imag<<c2.real<<c2.imag;// >>
  cout<<c.real<<'+'<<c.imag<<"="<<Add(c1,c2)<<endl; // complex是你自定义数据,谁知道你想输出什么
1