[求助]一个奇怪的错误!
#include<iostream>using namespace std;
class Saving
{
int user_num;
double money;
double account;
public:
Saving(int un,double mony=0.0,double acct=0.0);
double save(double mony)
{
account+=mony;
return account;
}
virtual void withdraw(double acct,double mony)=0;
double show()
{
return account;
}
};
class Saving1:public Saving
{ double q;
public:
Saving1();
Saving1(int un,double mony=0.0,double acct=0.0);
void withdraw(double acct,double mony)
{
q=show();
if(mony!=q)
{cout<<"money must be withdraw by one time"<<endl;}
else cout<<"you can get"<<mony*(1+0.5)<<endl;
}
};
class Saving3:public Saving
{
double q;
public:
Saving3();
Saving3(int un,double mony=0.0,double acct=0.0);
void withdraw(double acct,double mony)
{
q=show();
if(mony!=q)
{cout<<"money must be withdraw by one time"<<endl;}
else cout<<"you can get"<<mony*(1+0.8)<<endl;
}
};
class Saving5:public Saving
{
double q;
public:
Saving5();
Saving5(int un,double mony=0.0,double acct=0.0);
void withdraw(double acct,double mony)
{
q=show();
if(mony!=q)
{cout<<"money must be withdraw by one time"<<endl;}
else cout<<"you can get"<<mony*(1+0.8)<<endl;
}
};
/*class huoqi:public Saving{
double huoqi_lilv;
public:
void lixi(double qianshu)
{cout<<qianshu*(1+0.01);}
};*/
void fn(Saving &m)
{ char ch;
double sn,wn,q;
cout<<"choose your choice"<<endl;
cout<<"(S)ave or (W)ithdraw"<<endl;
cin>>ch;
if(ch=='s')
{cout<<"please input save num"<<endl;
cin>>sn;
m.save(sn);}
else
cout<<"please input withdraw num"<<endl;
cin>>wn;
q=m.show();
if(wn>q)
{
cout<<"your don't have enough money"<<endl;}
else
m.withdraw(q,wn);
}
void main()
{char c;
while(c=='q')
{
cout<<"enter 1 for one year save"
<<"enter 3 for one year save"
<<"enter 5 for one year save"
<<"enter q for quit"<<endl;
cin>>c;
if(c=='1')
{Saving1 s1;
fn(s1);}
else if(c=='3')
{Saving3 s3;
fn(s3);}
else if(c=='5')
{Saving5 s5;
fn(s5);}
}
}
error LNK2001: unresolved external symbol "public: __thiscall Saving5::Saving5(void)" (??0Saving5@@QAE@XZ)
12-4.obj : error LNK2001: unresolved external symbol "public: __thiscall Saving3::Saving3(void)" (??0Saving3@@QAE@XZ)
12-4.obj : error LNK2001: unresolved external symbol "public: __thiscall Saving1::Saving1(void)" (??0Saving1@@QAE@XZ)
Debug/12-4.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
大家帮忙看看错哪了?