2016-05-18 6 views
0

抽象クラスから継承することに問題があります。vtableへの未定義参照(継承)

抽象クラス - ヘッダファイル:

#ifndef CLIENT_H 
    #define CLIENT_H 
    #include "country.h" 
    #include "currency.h" 
    #include "item.h" 
    #include "order.h" 
    #include <string> 
    #include <vector> 

    using namespace std; 

    class Order; 

    class Client { 
     string first_name; 
     string last_name; 
     int account_balance; 
     Country country; 
     Currency currency; 
     vector <Order> orders; 

    public: 
     Client (string first_name, string last_name, Country country, Currency currency); 
     void buy_item (Item item, unsigned quantity, unsigned order_ID); 
     void add_order (unsigned ID); 
     virtual void pay (unsigned order_ID) = 0; // 
    }; 

    #endif // CLIENT_H 

抽象クラス - .cppファイル:

#include "client.h" 

    Client::Client (string first_name, string last_name, Country country, Currency currency) 
     : first_name(first_name), last_name(last_name), country(country), currency(currency) 
    { 
    account_balance = 0; 
    } 

継承するクラス - ヘッダファイル:

#ifndef ENGLISHCLIENT_H 
    #define ENGLISHCLIENT_H 
    #include "client.h" 
    #include <string> 

    using namespace std; 

    class EnglishClient : public Client { 
    public: 
     EnglishClient (string first_name, string last_name); 
     void pay (unsigned order_ID); 
    }; 

    #endif // ENGLISHCLIENT_H 

継承するクラス - 。 cppファイル:

#include "englishclient.h" 

    EnglishClient::EnglishClient (string first_name, string last_name) 
     : Client(first_name, last_name, GB, GBP) 
    { 
    } 

そして最後のエラー:あなたは、メソッドClient::buy_itemの実装を忘れてしまったClient::add_orderEnglishClient::pay

enum Country {GB, PL}; 

enum Currency {GBP, PLN}; 
+0

Clientクラスに仮想dtorがありますか? –

答えて

0

enter image description here

GBとGBP列挙型変数です

+0

私はこれらのメソッドを実装する前にこのコードをコンパイルできると考えました。 とにかく、それは今、たくさんの感謝:) –

0

EnglishClient::pay,Client::buy_itemまたはClient::add_orderを定義したことがありません。クライアントの場合は、それらを定義するか抽象的に設定するか((add_orderと同じ) `)、サブクラスで定義します。

+0

ありがとう、それは今働く:) –

関連する問題