So i'm working on a small program where I have to make a banking system using inheritance.
I have a bank account class, which is just, well, a general bank account. You can deposit, withdraw, and see the balance. I then have a business account class that inherits from the bank account class. The business account class is exactly the same, except that it allows overdrafts, meaning that my withdrawal function is different.
However, I end up changing the balance variable for the two classes. For example, If i deposit 500 dollars, the balance variable in the BankAccount class will be different than the balance variable in the BusinessAccount class. I thought of switching balance to protected, but I don't know if this will be considered good practice. What do you guys think?
Too true. C++ is not the best place to learn about Java and inheritance (or Java and operator overloading for that matter). Each has its own rationale for doing the 'perfect' job of a programming language but on those aspects alone there is a different attitude taken.