class complex//complex.h
{ int mi,mj;
public:
complex();
complex(int i,int j);
friend complex operator +(complex& x,complex& y);
friend complex operator -(complex& x,complex& y);
display();
};
#include "complex.h"//complex.cpp
#include <iostream.h>
#include "stdio.h"
complex::complex()
{mi=mj=0;
}
complex::complex(int i,int j)
{ mi=i;
mj=j;
}
complex::display()
{
cout<<mi<<"\t"<<"+"<<"\t"<<mj<<"i"<<endl;
}
complex operator +(complex& x,complex& y)
{ complex res;
res.mi=x.mi+y.mi;
res.mj=x.mj+y.mj;
return res;
}
complex operator -(complex& x,complex& y)
{ complex res(x.mi-y.mi,x.mj-y.mj);
return res;
}
void main()
{ complex x(1,2);
complex y(3,4);
complex a,b;
a=x+y;
b=x-y;
a.display();
b.display();
}
错误信息:unresolved external symbol _WinMain@16
1 unresolved externals