I\'m getting error C2039: \'setInterestRate\' : is not a member of \'SavingsAcco
ID: 3644045 • Letter: I
Question
I'm getting error C2039: 'setInterestRate' : is not a member of 'SavingsAccount' and error C2039: 'getNumberOfDays' : is not a member of 'SavingsAccount'Here is my codes for the 2 files that are showing up
BankAccountMain.cpp
#include "BankAccount.h"
#include "CheckingAccount.h"
#include "SavingsAccount.h"
#include <iostream>
#include <iomanip>
#include <windows.h>
using namespace std;
void main(void)
{
int i = 0;
int newAccountNumber = 0;
double depositAmount = 0.0;
double withdrawAmount = 0.0;
double newInterestRate = 0.0;
srand(GetTickCount()); //Seed the random number generator
////////////////////////////////////////////////////////////////////////
//Saving account Test;
CheckingAccount account1;
SavingsAccount account2;
cout << "Enter a six digit integer for your new savings account number: ";
cin >> newAccountNumber;
account2.setAccountNumber(newAccountNumber);
cout << endl;
cout << "Retrieving new savings account number" << endl;
cout << "New Savings Account Number: " << account2.getAccountNumber() << endl << endl;
cout << "Set savings account interest rate" << endl;
cin >> newInterestRate;
account2.setInterestRate(newInterestRate);
cout << "Savings account balance for account # " << account2.getAccountNumber() <<
" is $" << account2.getAccountBalance() << endl << endl;
cout << "Total interest earned: " << account2.getInterestEarned() << " over " << account2.getNumberOfDays()
<< " days" << endl << endl;
cout << showpoint << fixed << setprecision(2);
account2.depositMoney(100.0);
cout << "Savings account balance for account # " << account2.getAccountNumber() << " is $" << account2.getAccountBalance() << endl; // FIXED CODE
cout << "Total interest earned: " << account2.getInterestEarned() << " over " << account2.getNumberOfDays()
<< " days" << endl << endl;
for(i = 0; i < 10; i++)
{
cout << "Withdraw money from savings account" << endl;
if(account2.withdrawMoney(20.0) == false)
cout << "Withdrawal denied, insufficient funds" << endl;
cout << "Savings account balance for account # " << account2.getAccountNumber() <<
" is $" << account2.getAccountBalance() << endl;
cout << "Total interest earned: " << account2.getInterestEarned() << " over " << account2.getNumberOfDays()
<< " days" << endl << endl;
}
////////////////////////////////////////////////////////////////////////
// Checking Account Test
cout << "Enter a six digit integer for your new account number: ";
cin >> newAccountNumber;
account1.setAccountNumber(newAccountNumber);
cout << endl;
cout << "Retrieving new checking account number" << endl;
cout << "New Checking Account Number: " << account1.getAccountNumber() << endl << endl;
cout << "Checking account balance for account # " << account1.getAccountNumber() <<
" is $" << account1.getAccountBalance() << endl << endl;
cout << showpoint << fixed << setprecision(2);
account1.depositMoney(100.0);
cout << "Checking account balance for account # " << account1.getAccountNumber() <<
" is $" << account1.getAccountBalance() << endl << endl;
for(i = 0; i < 10; i++)
{
cout << "Withdraw money from checking account" << endl;
if(account1.withdrawMoney(20.0))
cout << "Monthly free transactions exceeded, $0.50 charge deducted from account" << endl << endl;
else
cout << "Withdrawal denied, insufficient funds" << endl;
cout << "Checking account balance for account # " << account1.getAccountNumber() <<
" is $" << account1.getAccountBalance() << endl << endl;
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SavingsAccount.h
#pragma once
#include "BankAccount.h"
class SavingsAccount :
public BankAccount
{
public:
SavingsAccount(void);
~SavingsAccount(void);
double getAccountBalance(void);
void SetInterestRate(double);
private:
double interestRate;
int numberofDays;
double earnedInterest;
public:
double getInterestEarned(void);
int getNumberofDays(void);
};
Explanation / Answer
I think the problem is just the case sensitivity of the methods. SetInterestRate has a capital S and getNumberofDays has a lowercase "o".
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.