2016-11-21 18 views
-1

編集:顧客クラスを作成しようとしていますが、機能に問題があります。複数の継承関数

以下の指示に従います。新しいクラスの導出 - 得意先クラス(貯蓄からの継承 - 銀行口座からの継承) 顧客クラスを作成します。顧客クラスは、私の機能を修正する方法上の任意の方向が

#include "BankAccount.h" 
#include "SavingsAccount.h" 
#include <iostream> 

class Customer : public SavingsAccount, public BankAccount { 
protected: 
    string CustomerName; 

public: 
    string getCustomerName(); 
    void setCustomerName(string); 

    void WithdrawSavings(){ Customer c; c.BankAccount::balance(); } 
    void DepositSavings(double); 

    Customer(){ 
     CustomerName = ""; 

    } 
}; 
+4

ここには明らかな問題が多すぎます。このコンパイルエラーだけでなく、より根本的な問題があります。この質問は回収可能ではありません... –

+1

'Customer'は' SavingsAccount'と 'BankAccount'ですか? –

答えて

1

ここで混乱している継承の使用を助ける

次の新しい属性 顧客名を持っています。それは、より多くのようになります。

class BankAccount { 
    // whatever 
}; 

class SavingsAccount : public BankAccount { 
    // whatever 
}; 

class Customer { 
    SavingsAccount savings; 
}; 

これはSavingsAccountBankAccountで、CustomerSavingsAccountを持っていることを言います。

+0

オリジナルの投稿が 'SavingAccount' +' CurrentAccount'としてうまくいったのだろうかと思います。 –

+0

@JoeS - 答えとして投稿してください。そうすれば、いくらか不正確な記述の代わりに実際のコードを書くことができます。 –