<<< What is inheritance?     Index     Inheritance interactions >>>

10. Inheritance example

  • Base class:

    
    class Account {
    public:
        Account();
        bool sell( string symbol, int shares );
        bool buy( string symbol, int shares );
        bool deposit( double amount );
        bool withdraw( double amount );
    
    private:
        double m_cash_balance;
        static const int SIZE = 100;
        string m_holding_symbols[ SIZE ];
        int m_holding_shares[ SIZE ];
    
    };//class Account
    
    
  • Derived class:

    
    class GoldAccount : public Account {
    public:
        GoldAccount();
        virtual ~GoldAccount();
        bool credit_interest();
    
    private:
        int m_margin_balance;
        std::string m_person_name;
    
    };// class GoldAccount
    
    
<<< What is inheritance?     Index     Inheritance interactions >>>