Hello all expert C++ programmer, i truly new to C++ programming. 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 */ Implementation File: 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 : I hope someone cna help me out. Thanks for your help. Your help is greatly appreciated by me and others.
I cannot understand what you are trying to do. I don't see any one parameter constructor for your class savingAccount but your error suggest it has one with a const parameter. If thats the case convert your int parameter into const int
What is the reason of having explicit constructor? Where is the defintion of constructor corresponding to Code: savingAccount peter(2000);
No definition for Single argument constructor in ur program If u want a simple solution means add the following line to ur header file savingAccount(double balance):balance(balance){} so that u got an answer...........