I have a exercise where need to calculate the monthly interest with the balance supplied.
Header File:
Code:
#pragma once
class savingAccount
{
static double annualInterestRate;
double balance;
double monthlyInterest;
public:
savingAccount() : balance(0), monthlyInterest(0){}
explicit savingAccount(double balance, double monthlyInterest)
:balance(balance), monthlyInterest(monthlyInterest){}
void calMonthlyInterest();
static void modifyInterestRate();
~savingAccount(){}
};
/* Static data member cannot initialized
by constructor
*/
Code:
#include<iostream>
#include<cstdlib>
#include "Saving Account.h"
using std::cout;
using namespace std;
double savingAccount::annualInterestRate = 0.05;
int main(int argc, char *argv[])
{
savingAccount peter(2000);
savingAccount nicholas_tse(3000);
peter.calMonthlyInterest();
return EXIT_SUCCESS;
}
// -----------------------------------------
void savingAccount::calMonthlyInterest()
{
monthlyInterest = (balance * annualInterestRate)/12;
}
// -----------------------------------------
Error Message :
Quote:
Error 1 error C2664: 'savingAccount::savingAccount(const savingAccount &)' : cannot convert parameter 1 from 'int' to 'const savingAccount &' d:\c++\saving account\saving account\saving account.cpp 12
Error 2 error C2664: 'savingAccount::savingAccount(const savingAccount &)' : cannot convert parameter 1 from 'int' to 'const savingAccount &' d:\c++\saving account\saving account\saving account.cpp 13
Thanks for your help.
Your help is greatly appreciated by me and others.


