Formula not returning a sum

Hi, could someone tell me why this function in my header is not returning the
balance = depAmount + balance
back to Main?
Thank you!!


double SavingsAccount::getdepAmount()
{
//get deposit amount
cout << endl;
cout << "Great. How much will you be depositing today? $";
cin >> depAmount;
cout << endl;

return depAmount;
}

void SavingsAccount::addToBalance(double)
{
//get equation to use for the current balance
balance += depAmount;
}
Hi, could someone tell me why this function in my header is not returning the
balance = depAmount + balance
back to Main?

Um, it's not returning it, because you haven't told it to return it! You've defined the function to be of type void, which means it doesn't return anything.

EDIT: And nowhere in the code you've posted do I see any definition for the variables balance or depAmount used in addToBalance(). What are they? Global variables? Data members?

Does this code even compile?
Last edited on
Hi lili143

It is better to keep the original topic going, rather than start a new one. It's just more efficient & everyone knows what's going on.

http://www.cplusplus.com/forum/beginner/104627/


Good Luck with your coding 8+)

Last edited on
Sorry I'm new to this so I thought new questions = new posts.. Thank you! :)
Topic archived. No new replies allowed.