Exhausted my resources on function does not take 0 arguments error

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;

#include "SavingsAcct.h"

int main()
{
//declare variables
std::string ACCTNUM = "123456789";
char deposit = ' ';
double depAmount = 0.0;

//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;

if (deposit == 'Y' || deposit == 'y')
{

double getdepAmount();

}//end if

balance = myAccount.addToBalance();
double addToBalance();

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


//////////////////HEADER FILE//////////////////

class SavingsAccount
{
//Data declarations
private:
//string accountNum;
double balance;
double intRate;
double depAmount;

//Methods declarations
public:
SavingsAccount();
//string getAcctNum();
double getBalance();
double getdepAmount();
double getIntRate();
//void setAcctNumber(string);
//void setIntRate(double);
void addToBalance(double);
//void withdrawFromBalance(double);
};
//END OF CLASS SavingsAccount


//Methods implementation

//This is the constructor
SavingsAccount::SavingsAccount()
{
balance = 7000.0;
intRate = 0.25;
}

double SavingsAccount::getBalance()
{
return balance;
}

//double SavingsAccount::getIntRate()
//{
//return intRate;
//}

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;
}
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:
1
2
balance = myAccount.addToBalance();
double addToBalance();


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 :)

Thank you again!
Ashleigh
By the way, here is my successfully compiled code and I cleaned up some things too just if youre interested

//////////////////SOURCE CODE//////////////////
#include "SavingsAcct.h"

int main()
{
//declare variables
std::string ACCTNUM = "123456789";
char deposit = ' ';
double depAmount = 0.0;
//double newBalance = 0.0;

//create one instance of a SavingsAccount
SavingsAccount myAccount;
double balance = 0.0;
double intRate = 0.0;

balance = myAccount.getBalance();
intRate = myAccount.getIntRate();

//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();

}//end if

myAccount.addToBalance(balance);
//void addToBalance();

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

//////////////////HEADER FILE//////////////////
class SavingsAccount
{
//Data declarations
private:
//string accountNum;
double balance;
double intRate;
double depAmount;
double rate;

//Methods declarations
public:
SavingsAccount();
//string getAcctNum();
double getBalance();
double getDepAmount();
double getIntRate();
//void setAcctNumber(string);
//void setIntRate(double);
void addToBalance(double);
//void withdrawFromBalance(double);
};
//END OF CLASS SavingsAccount

//Methods implementation

//This is the constructor
SavingsAccount::SavingsAccount()
{
balance = 7000.0;
intRate = 0.25;
}

double SavingsAccount::getBalance()
{
return balance;
}

double SavingsAccount::getIntRate()
{
return intRate;
}

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 new balance
balance += depAmount;
}

//////////////////////////////////////

//void SavingsAccount::setIntRate(double);
//{
//balance *= rate;
//}
Topic archived. No new replies allowed.