I need to turn a struct into a class. The class needs to display bank account details - first cheque account and then an updated member function to update the details to a savings account. I am able to display the details of the cheque but having troubles with the updateAccounnt() member function. Please see the question below:
"Mrs Sithole realises that a savings account will provide a higher interest rate. Now add a member function updateAccount() to the class BankAccount to change the type of bank account as well as the interest rate. Then test your updateAccount() member function by changing the type of Mrs Sithole’s bank account to a savings account with 0.06% interest. Display the details of her new account on the screen."
Okay, I deleted the other variables and added myAccount. I am still not able to get an output for the updated version of the savings account. The output only shows me the information in int main. Please check edited code below:
The output only shows me the information in int main
You never call the updateAccount function. That function should not create another temporary myAccount object (not the same as the one in main), instead pass the myAccount object from main to the updateAccount function as an argument.
Edit: The Update Account function should also take const arguments for the things that will change.
Functions should only do 1 conceptual thing: updating and printing information is 2 things.
Instead of calling lots of set functions, consider writing a constructor to set all the values at once when the object is created. Set functions can be used after the fact IF something needs to change.
In the same manner, write one function to do output. It's better than calling them all from main.
Good Luck !!
Edit:
Go and research the things I mentioned, will be good to see your new code.