简单的C++问题。
程序代码:
#include<iostream> using namespace std; class Complex{ public: double real; double image; Complex(); Complex(double a,double b){real=a;image=b;} //Complex Add(double a,double b);//两复数相加 Complex Add(Complex c);//两复数相加结果是复数 /*Complex Sub(double a,double b);//两复数相 Complex Sub(Complex c);//两复数相减结果是复数 bool IsEqual(Complex c);//两复数是否相等 Complex Multiply(Complex c);//两复数相乘 Complex Power(int n);//当前复数的n次方 Complex Divide(Complex c);//两复数相除 double GetModal();//模 void Zoom(double x);//将复数扩大X倍*/ void ShowMe(); }; Complex Complex::Add(Complex c){ return Complex(real+c.real,image+c.image); } /*Complex Complex::Add(double a,double b){ return Complex(real+a,image+b); }*/ void Complex::ShowMe(){ if(image<0.0) cout<<real<<image<<"i"<<endl; else cout<<real<<"+"<<image<<"i"<<endl; } int main() { Complex x(1,2),y(3,4); Complex c1; c1=x.Add(y); c1.ShowMe(); return 0; }不清楚总是在build的时候出现错误。
--------------------Configuration: 1 - Win32 Debug--------------------
Linking...
1.obj : error LNK2001: unresolved external symbol "public: __thiscall Complex::Complex(void)" (??0Complex@@QAE@XZ)
Debug/1.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
1.exe - 1 error(s), 0 warning(s)
该怎么修改呢?