So this is what i need to do and its not coming out right in my code. A function to calculate how long the balance will take to grow to a given value. This function is not part of the account class. It should take two arguments: an object of the account class and a target value. It should return how long should pass until the balance on the account object reaches the target value.
The account object must be a const reference parameter so that inside the function, you call the function to add interest to the balance as many times as needed without actually modifying the object.
I'm not getting how to make the object a const reference parameter.
This is my code. at the end i put a formula im not sure if i did it right. also whenever the program runs there is a zero next to balance and interest when i ask the user to enter there intial balance and interest.
By the way the object of my BankAccount Class is Checking
int calculate_growth_span(const BankAccount& account, double target)
That's how you pass a const reference. Const means that within the function the object will not be altered. Passing by reference makes sure that you only pass the address of the existing object to the function, as opposed to a copy of the original. That means that if you didn't declare this parameter const, you would be altering the exact same object which you passed in.
I'll leave the implementation of the function up to you, but do not hesitate to ask if you require any further help.