Hi all,

I need help understanding a C++ problem. This is an assignment question.

Create a base class ‘Account’ and two derived classes ‘Savings’ and‘Checking’.
The ‘Savings’ and ‘Checkings’ information should be connected to each other using variable CREDITRATING.

Transactions in any of those derived classes should be able to manipulate CREDITRATING.

How can i do that? I have few ideas (i may be wrong)

  • declare CREDITRATING in base class as protected?
  • using friend function
  • by declaring CREDITRATING as a static member

But from a security aspect, which is the best choice?

Please help. Thanks

Edited by Thomas_25: forgot to mention

3 Years
Discussion Span
Last Post by Thomas_25

Specify CREDITRATING as a private member, but provide a protected setter and public getter method to set/get the data. Don't use friend or static members or methods for that. In your derived class, if you need to change the credit rating based upon some analytical processes, then you can call the protected base class setter function, but it keeps any old code from being able to change it without thought.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.