小白,敲课本的代码,出现错误,这是我第一次出现这样的错误,根本无从下手,请教大神出手相救。。。
--------------------Configuration: 具有构造函数的类1 - Win32 Debug--------------------
Linking...
具有构造函数的类1.obj : error LNK2001: unresolved external symbol "public: void __thiscall BankAccout::output(class std::basic_ostream > &)" (?output@BankAccout@@QAEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@
@Z)
Debug/具有构造函数的类1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
具有构造函数的类1.exe - 2 error(s), 0 warning(s)
//该程序用于演示BackAccount 类
#include
using namespace std;
//定义银行账户的类
class BankAccout
{
public:
BankAccout(int dollars , int cents , double rate );
//将账户余额初始化为¥dollars.cents 将利率初始化为利率百分比
BankAccout(int dollars ,double rate);
//将账户余额初始化为¥dollars.00 将利率初始化为利率百分比
BankAccout();//默认构造函数
//将账户余额初始化为0.00 将利率初始化为0.0%
void update();
//后条件:将1年的单利添加到账户余额上
//将当前账户利率作为一个百分比返回
double get_rate ();
//返回当前账户余额
double get_balance();
void output (ostream &outs);
private:
double balance ;
double interest_rate ;
//将百分比转换成小数
double fraction(double percent);
};
int main ()
{
BankAccout account1(100 , 2.3) , account2 ;
cout <<"account1 initialized as follows :\n";
account1.output(cout);
cout << "account2 initialized as follows : \n" ;
account2.output(cout);
//对构造函数BankAccount::BankAccount 的显示调用
account1 = BankAccout(999 , 99 , 5.5);
cout << "account1 reset to the following :\n";
account1.output(cout);
return 0 ;
}
//将账户余额初始化为&dallors.00将利率初始化为利率百分比
BankAccout::BankAccout(int dollars ,int cents , double rate)
{
if ((dollars < 0 ) ||(cents < 0 ))
{
cout <<"Illegal values for money or interest rate .\n";
exit(1);
}
balance = dollars + 0.01 * cents;
interest_rate = rate ;
}
//将账户余额初始化为&dallors.00 将利率初始化为利率百分比
BankAccout::BankAccout(int dollars , double rate )
{
if ((dollars < 0 ) || (rate < 0 ))
{
cout <<"Illegal values for money or interest rate .\n";
exit(1);
}
balance = dollars ;
interest_rate = rate ;
}
BankAccout::BankAccout():balance(0) , interest_rate(0.0)
{
//主体有意留空
}