2013-11-25 1 views
0

C++에서 은행 시스템의 모델을 만들고 있으며 기본 계정 인 Account 클래스에서 상속 한 여러 계정 유형이 있습니다. 내 .h 및 .cpp 파일을 외부 라이브러리로보고 있지 않으면 컴파일러에 외부 라이브러리를 사용하고 있다고 생각하지 않기 때문에 LNK 오류의 원인을 정확히 알 수 없습니다.외부 기호를 해결하는 방법

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 ========== 

그리고 여기에 다른 클래스의 모든

#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); 
}; 

에서 내가 상속하고 방법의 예로 상속 Account.h 파일입니다 : 나는 점점 오전 오류 목록입니다

#pragma once 
#include "Account.h" 

class StudentSavings:public Account 
{ 
    //stuff 
}; 
+5

어디서나 'Account' 클래스에 멤버 함수 (구체적으로 생성자와 소멸자)를 실제로 구현 했습니까? 그 파일을 가지고 건축하고 있습니까? –

+0

2/3 생성자를 구현하고 있었는데 지금은 1 개의 외부 확인되지 않은 질문 만 업데이트합니다. – Yann

+1

이제 질문은 'CurrentAccount'에 대한 소멸자를 구현 했습니까? – john

답변

1

가상 소멸자를 정의하지 않았습니다.
오류 메시지는 정의되지 않은이 기호임을 명확하게 알려줍니다.

virtual ~Account() {} 

링커는 타사 라이브러리뿐 아니라 사용자 정의 코드의 모든 정의와 기호에도 사용할 수 있습니다. 사용시 (가상 소멸자는 항상 "사용"됨)이 값을 제공해야합니다.

관련 문제