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

Recommended Answers

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 …

Jump to Post

All 2 Replies

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.

Great.. Makes sense. Thanks a lot @rubberman.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.