Hello, I have been working a long time(days) trying to resolve this error. I have researched online, gone through my chapter, notes, slides, and even asked my husband (who uses SQL but not c++). I am to the point of not knowing if I'll be able to wrap my head around this and if programming is even the way to go for me : /
Any help with this error would be greatly appreciated!
Many thanks in advance.
This is my error:
error C2660 : 'SavingsAccount::addToBalance' : function does not take 0 arguments
This is my code:
//////////////////SOURCE CODE//////////////////
#include <iostream>
#include <string>
using namespace std;
//Create one instance of a SavingsAccount
SavingsAccount myAccount;
double balance = 0.0;
balance = myAccount.getBalance();
//provide initial balance and enter input items
cout << "Hello, Mr. Smith." << endl;
cout << "Your initial balance for Account Number " << ACCTNUM << endl;
cout << " is $" << balance << "." << endl;
cout << endl;
cout << "Will you be making a deposit today?" << endl;
cout << "(Please type Y for Yes or N for No.) ";
cin >> deposit;
cout << "Mr. Smith, your current balance including the" << endl;
cout << "deposit of $" << depAmount << " is: $" << balance << endl;
cout << endl;
cout << "Thank you and have a great day!" << endl;
system("pause");
return 0;
} //end of main function
As you get more comfortable with programming, you will find that compiler errors are actually more helpful than they might seem. The error you get might not make sense to you, but when I see that, what comes to mind is that somewhere in your code, you are calling a method of the class SavingsAccount which is supposed to take 1 parameter; and you can calling it with zero parameters. http://www.cplusplus.com/doc/tutorial/functions/
Look through your code and you will find the following lines:
The first one is what is giving you problems. First the function does not return anything since it is of type void. And second, it takes a double value as a parameter. To fix this, you have to do myAccount.addToBalance( balance );
As for the second line, it might not be doing what you think it is supposed to do. So delete it or leave it there if you have a use for it
Thank you so much. I have made some adjustments per your comments, and it has successfully compiled! However I'm now getting some incorrect math in the output : /
I am going to keep plugging away, and hopefully I will not be posting about basic addition in the coming hours :)
//provide initial balance and interest rate and enter input items
cout << endl;
cout << "Hello, Mr. Smith." << endl;
cout << endl;
cout << "Your initial balance for Account Number " << ACCTNUM << endl;
cout << " is $" << balance << "." << endl;
cout << endl;
cout << "Your current interest rate is " << intRate << "%." << endl;
cout << endl;
cout << "Will you be making a deposit today?" << endl;
cout << "(Please enter Y for Yes or N for No.) ";
cin >> deposit;
//enter input items if making deposit
if (deposit == 'Y' || deposit == 'y')
{
depAmount = myAccount.getDepAmount();
cout << "Mr. Smith, your current balance including the" << endl;
cout << "deposit of $" << depAmount << " is: $" << balance << endl;
cout << endl;
cout << "Thank you for banking with us, and have a great day!" << endl;
system("pause");
return 0;
} //end of main function