请问这程序为什么编译会出错,怎么样修改
文件1.h#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);
operator double () { return real; }
void display() const;
private:
double real;
double imag;
};
complex operator+(complex &c1,complex &c2)
{
return complex( c1.real+c2.real,c1.imag+c2.imag);
}
void complex::display() const
{
cout<<"("<<real<<","<<imag<<"i)"<<endl<<endl;
}
文件2.cpp
#include"1.h"
int main()
{
complex c1(5,3),c2(5,4),c;
double d;
c1.display();
c2.display();
cout<<"c=c1+c2 = ";
c=c1+c2;
c.display();
cout<<"2.5+c1 = ";
c=2.5+c1;
c.display();*/
cout<<"c1+2.5 = ";
c=c1+2.5;
c.display();
cout<<"complex c=2.5+2.5 = ";
c=2.5+2.5;
c.display();
cout<<"double d=2.5+c1 = ";
d=2.5+c1;
cout<<d<<endl<<endl;*/
return 0;
}
编译时的错误显示:
Compiling...
2.cpp
e:\程序a\1232\1.h(13) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
执行 cl.exe 时出错.
2.obj - 1 error(s), 0 warning(s)