0
我正在C++中創建銀行系統的模型,並且有多個帳戶類型,均從基類Account繼承。我不確定究竟是什麼導致LNK錯誤,因爲我不相信我正在使用外部庫到編譯器,除非它正在查看我的.h和.cpp文件作爲外部庫。我正的錯誤列表是:如何解決外部符號
1>------ Build started: Project: Bank, Configuration: Debug Win32 ------
1> Account.cpp
1>CurrentAccount.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall CurrentAccount::~CurrentAccount(void)" ([email protected]@[email protected]) referenced in function "public: virtual void * __thiscall CurrentAccount::`scalar deleting destructor'(unsigned int)" ([email protected]@[email protected])
1>H:\C++ Assignment\Bank\Debug\Bank.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
這裏是Account.h文件,所有其他類的從
#pragma once
#include "Person.h"
using namespace std;
class Account
{
public:
enum AccountType {Current, JrCurrent, StdntSavings, CorpSavings, PersonalLoan, CorpLoan, Mortgage, GuaranteeCard, CreditCard, GFInvestment, EFInvestment, Pension};
Account(double balance, double interestRate, Person accountHolder);
Account(double balance, double interestRate, Person accountHolder, AccountType type);
Account(){};
virtual ~Account();
double getBalance(), getInterestRate();
Person getAccountHolder();
void deposit(double amount), changeInterest(double newInterest), calculateInterest();
bool isType(AccountType type);
bool hasFunds();
bool withdraw(double amount);
string toString();
protected:
Person accountHolder;
double balance, interestRate, creditLimit;
AccountType accType;
friend ostream& operator<<(ostream &out, Account& other);
};
正如我如何繼承的例子繼承:
#pragma once
#include "Account.h"
class StudentSavings:public Account
{
//stuff
};
你是否真的在'Account'類的任何地方實現了成員函數(具體來說,構造函數和析構函數)?你正在建立該文件嗎? –
我正在實現2/3的構造函數,現在我只有1個未解析的外部函數,將更新問題 – Yann
現在問題是,您是否實現了'CurrentAccount'的析構函數? – john