# include <iostream>
# include <string>
using namespace std;
class Account
{
private:
string name;
double balance;
static double rate;
public:
Account(string n,double b): name(n), balance(b){}
Account();
~Account() {}
Account(const Account& ac)
{}
Account& operator = (const Account& ac);
void Display () const;
double passyear(int);
static void SetRate(double);
};
Account& Account:: operator = (const Account& ac)
{
name = ac.name;
balance = ac.balance;
rate = ac.rate;
return *this;
}
void Account::Display() const
{
cout<<"name "<<name<<" balance "<<balance<<endl;
}
void Account::SetRate(double r)
{
rate = r;
}
double Account:: passyear(int)
{
balance = (1 + rate) * balance;
return balance;
}
int main()
{
Account::SetRate(0.35); //设置年利率
Account ac1("ligang",1000.0); //创建账户名ligang, 余额为1000.0的帐户
Account ac2(ac1);
Account ac3;
ac3=ac1=ac2;
ac3.passyear(1); //计算1年后的余额
ac1.Display(); //显示账户名及余额
ac2.Display();
ac3.Display();
return 0;
}
考试1.obj : error LNK2001: unresolved external symbol "public: __thiscall Account::Account(void)" (??0Account@@QAE@XZ)
链接时报错 QAQ