May 11, 2018 at 9:38pm UTC
Hello, can someone help me? Trying to figure something out and I can't see it.
I'm getting error: no 'void Account::setannualInterestRate(double)' member function declared in class 'Account'
void Account::setannualInterestRate(double rate)
Account.h
#ifndef ACCOUNT_H
#define ACCOUNT_H
class Account {
public:
Account();
Account(int i,double bal,double rate);
int getld();
double getBalance();
double getAnnualInterestRate();
void setld(int i);
void setBalance(double bal);
void setAnnualInterestRate();
double getMonthlyInterestRate();
void withdraw(double amount);
void deposit(double amount);
private:
int id;
double balance;
double annualInterestRate;
};
#endif
TestAccount.cpp
#include <iostream>
#include "Account.h"
using namespace std;
int main()
{
int id = 1122;
float balance = 20000;
float annualInterestRate = 4.5;
Account a(id,balance,annualInterestRate);
cout << "\nAfter withdrawing $2500";
a.withdraw(2500);
cout << "\nBalance: $" << a.getBalance();
a.deposit(3000);
cout << "\nAfter Deposit of $3000";
cout << "\nBalance: $" << a.getBalance();
cout << "\nMonthly Interest is: " << a.getMonthlyInterestRate() << endl;
getchar();
return 0;
}
Account.cpp
#include "Account.h"
#include <iostream>
using namespace std;
Account::Account()
{
id = 1122;
balance = 20000;
annualInterestRate = 4.5;
}
Account::Account(int i,double bal,double rate)
{
id = i;
balance = bal;
annualInterestRate = rate;
}
int Account::getld()
{
return id;
}
double Account::getBalance()
{
return balance;
}
double Account::getAnnualInterestRate()
{
return annualInterestRate;
}
void Account::setld(int i)
{
id = i;
}
void Account::setBalance(double bal)
{
balance = bal;
}
void Account::setannualInterestRate(double rate)
{
annualInterestRate = rate;
}
double Account::getMonthlyInterestRate()
{
double monthlyInterestRate = annualInterestRate/1200;
return monthlyInterestRate;
}
void Account::withdraw(double amount)
{
if(amount > balance)
{
cout << "\nSorry insufficient balance for transaction.";
}
else
{
balance = balance-amount;
}
balance = balance + amount;
}
May 11, 2018 at 9:50pm UTC
you declared void setAnnualInterestRate();
which takes no arguments