oop - Using a function inside of a C++ class inheritance -


i trying call function calculateinterest() in class

// account.h -- handles banking accounts #ifndef account_h_ #define account_h_ #include <string> using std::string;  class account { private:     double balance; public:     account(double b = 0.0);     double getbalance() {return balance;}     void credit(double c);     void debit(double d);  };  class savingsaccount : public account { private:     double rate; public:     savingsaccount(double r = 0.0);     double calculateinterest(); };    class checkingaccount : public account { private:     double fee; public:     checkingaccount(double f = 0.0);     void credit(double m);     void debit(double m); };   #endif 

so far account joe(100); , use functions inside of account class not inheriting right.

class account { private:     double balance; public:     account(double b = 0.0);     double getbalance() {return balance;}     void credit(double c);     void debit(double d);      // add this!     virtual double calculateinterest() = 0; }; 

you need implement calculateinterest in derived classes


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -