>>i need a detail explanation how the program work
I assum then that you did not write that code? If you had then you would know how it works.
What part(s) do you need help with?
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>>Create derived class Saving of a saving account
class Saving : public Bank
{
// put class objects/methods here
};
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
It is using uninitialized variables -- initialbal was never set to anything. You need to code a default constructur that initializes all variables to 0 or some other known value. Don't assume the compiler will do this for you because it won't.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
You need to put the [CODE] tags around the area of text where your code is
To create a derived class which inherits from Bank is as simple as
class saving : public Bank
{
// saving-specific code in here
};
Also, I have some general questions about this entire thread:
1) Isn't overkill to have functions defined for EVERY mundane thing such as name and account entry, etc?
2) wouldn't it be simpler if the base class included many of the functions into one all encompasing one like getAccount()?
3)I guess the derived class would satisfy the "Is a" qualification for inheritance in this case? This would only require very minor modification of the base class if I understand the proper application of these things...
Sorry to crash the thread like this, but i thought these questions might help both of us.
JRM
Practically a Master Poster
621 posts since Nov 2006
Reputation Points: 130
Solved Threads: 75