Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4565136
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:36:00+00:00 2026-05-21T18:36:00+00:00

Ive been up for a while coding and it is probably an easy mistake

  • 0

Ive been up for a while coding and it is probably an easy mistake that im just overlooking from lack of sleep, but the problem happens with this segment of code.

do
{
    aWithIntAcct.enterAccountData();
    aWithIntAcct.getSavInfo();
    aWithIntAcct.getCheckingInfo();
    checkAcct.push_back(aWithIntAcct);
    cout << "Would you like to enter another Checking Account with interest? y or n ";
    cin >> quitChar;
}while(quitChar != QUIT);

it says that I have ambiguous access of ‘enterAccountData’ (Error C2385)
This is contradictory to the other (Error C3861) identifier not found.

My Classes are inherited so im not sure why this inst working for me. Any suggestions?

REST OF CODE:

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
template <class T>
void repeatValue(T val, int times)
{
for(int x = 0; x < times; x++)
{
    cout << "-";
}
};
template <class T>
void produceReport(int tableRows, string title, T acctType)
{
cout << tableRows << endl;
cout << title << endl;
cout << acctType;
};

class BankAccount
{
friend ostream& operator<<(ostream&, const BankAccount&);
friend istream& operator>>(istream&, BankAccount&);
private:
int acctNum;
double acctBal;
public:
BankAccount(int = 0,double = 0.0);

double operator+=(BankAccount);
int operator+(BankAccount);
friend bool operator>(BankAccount &acctBalOne, BankAccount &acctBalTwo);
friend bool operator<(BankAccount &acctBalOne, BankAccount &acctBalTwo);
int operator==(const BankAccount acctNumOne);
void enterAccountData();
void displayAccount();
void setAcctNum(int);
void setAcctBal(double);
int getAcctNum();
double getAcctBal();
};
BankAccount::BankAccount(int num, double bal)
{
acctNum = num;
acctBal = bal;
}
double BankAccount::operator+=(BankAccount bankAcct)
{
acctBal += acctBal + bankAcct.acctBal;
return acctBal;
}
int BankAccount::operator+(BankAccount newAcctNum)
{
const int INCREMENT = 1;
newAcctNum.acctNum = acctNum + INCREMENT;
return newAcctNum.acctNum;
}
bool operator>(BankAccount &acctBalOne, BankAccount &acctBalTwo)
{
return acctBalOne.acctBal > acctBalTwo.acctBal;
}
bool operator<(BankAccount &acctBalOne, BankAccount &acctBalTwo)
{
return acctBalOne.acctBal < acctBalTwo.acctBal;
}
int BankAccount::operator== (const BankAccount acctNumOne)
{
int truth = 0;
if(acctNum == acctNumOne.acctNum)
    truth = 1;
return truth;
}
ostream& operator<<(ostream& display, const BankAccount& aAcct)
{
display << "Account #" << aAcct.acctNum << endl;
display << "Account Balance $" << aAcct.acctBal << endl;
return display;
}
istream& operator>>(istream& dataIn, BankAccount& aAcct)
{
cout << endl << "Enter in an Account # ";
dataIn >> aAcct.acctNum;
cout << "Enter in an Account Balance $ ";
dataIn >> aAcct.acctBal;
return dataIn;
}
void BankAccount::enterAccountData()
{
cout << "Enter the Account:#";
cin >> acctNum;
cout << endl << "Enter the Account Balance:$";
cin >> acctBal;
}
void BankAccount::displayAccount()
{
cout << "The Account number is #" << acctNum << endl;
cout << "The Account Balance is $" << acctBal << endl;
}
void BankAccount::setAcctNum(int num)
{
acctNum = num;
}
void BankAccount::setAcctBal(double bal)
{
acctBal = bal;
}
int BankAccount::getAcctNum()
{
return acctNum;
}
double BankAccount::getAcctBal()
{
return acctBal;
}
class SavingsAccount : public BankAccount
{
friend ostream& operator<<(ostream&, const SavingsAccount&);
private:
double interest;
public:
SavingsAccount(double = 0.0);
void displaySavAccount();
void getSavInfo();
};
SavingsAccount::SavingsAccount(double intRate)
{
interest = intRate;
}
void SavingsAccount::getSavInfo()
{
cout << "Enter Interest Rate: ";
cin >> interest;
}
ostream& operator<<(ostream& display, SavingsAccount& aSavAcct)
{
aSavAcct.displaySavAccount();
return display;
}
void SavingsAccount::displaySavAccount()
{
cout << "     Savings information.     " << endl;
cout << "Interest Rate on the account is:" << interest << endl;
}
class CheckingAccount : public BankAccount
{
friend ostream& operator<<(ostream& display, const CheckingAccount& aCheckAcct);
private:
double monthlyFee;
int checksAllowed;
public:
CheckingAccount(double = 0,int = 0,int = 0,double = 0);
void displayCheckAccount();
void getCheckingInfo();
};
CheckingAccount::CheckingAccount(double fee, int allowed, int num, double bal) :      BankAccount(num,bal), monthlyFee(fee), checksAllowed(allowed)
{

}
void CheckingAccount::getCheckingInfo()
{
cout << "Enter monthly fee of the Account for the checking account. $";
cin >> monthlyFee;
cout << endl << "How many checks are allowed?" << endl;
cin >> checksAllowed;
}
ostream& operator<<(ostream& display, CheckingAccount& aCheckAcct)
{
aCheckAcct.displayCheckAccount();
return display;
}
void CheckingAccount::displayCheckAccount()
{
cout << "           Checking Information           " << endl;
BankAccount::displayAccount();
cout << "Monthly fee on the account is:$" << monthlyFee << endl;
cout << "Checks allowed for this account is: " << checksAllowed << endl;
}
class CheckingWithInterest : public SavingsAccount, public CheckingAccount
{
private:

public:
CheckingWithInterest();
void displayWithInterest();
};
CheckingWithInterest::CheckingWithInterest() : CheckingAccount(0,0,9999,0), SavingsAccount(0.03)
{}
void CheckingWithInterest::displayWithInterest()
{
CheckingAccount::displayCheckAccount();
SavingsAccount::displaySavAccount();
}
int main()
{
cout << fixed << setprecision(2);

unsigned count;
vector<SavingsAccount>savAcct;
SavingsAccount aSavAcct;
vector<CheckingAccount>checkAcct;
CheckingAccount aCheckAcct;
vector<CheckingWithInterest>withIntAcct;
CheckingWithInterest aWithIntAcct;
const char QUIT = 'n';
char quitChar = 'y';
cout << "Do you want to enter Savings Information? y or n ";
cin >> quitChar;
do
{
    aSavAcct.enterAccountData();
    aSavAcct.getSavInfo();
    savAcct.push_back(aSavAcct);
    cout << "Would you like to enter another Savings Account? y or n ";
    cin >> quitChar;
}while(quitChar != QUIT);
cout << "Do you want to enter Checking Information? y or n ";
cin >> quitChar;
do
{
    aCheckAcct.enterAccountData();
    aCheckAcct.getCheckingInfo();
    checkAcct.push_back(aCheckAcct);
    cout << "Would you like to enter another Checking Account? y or n ";
    cin >> quitChar;
}while(quitChar != QUIT);
cout << "Do you want to enter Checking with interest account Information? y or n ";
cin >> quitChar;
do
{
    aWithIntAcct.enterAccountData(); // error points here for both (Line 233)
    aWithIntAcct.getSavInfo();
    aWithIntAcct.getCheckingInfo();
    checkAcct.push_back(aWithIntAcct);
    cout << "Would you like to enter another Checking Account with interest? y or n ";
    cin >> quitChar;
}while(quitChar != QUIT);

sort(savAcct.begin(), savAcct.end());
for(count = 0; count < savAcct.size(); ++count)
{
    repeatValue(savAcct.at(count), count);
    cout << endl;
    produceReport(savAcct.size(), "Savings Account Information", savAcct.at(count));
}
sort(checkAcct.begin(), checkAcct.end());
for(count = 0; count < checkAcct.size(); ++count)
{
    repeatValue(checkAcct.at(count), count);
    cout << endl;
    produceReport(checkAcct.size(), "Checking Account Information", checkAcct.at(count));
}
sort(withIntAcct.begin(), withIntAcct.end());
for(count = 0; count < withIntAcct.size(); ++count)
{
    repeatValue(withIntAcct.at(count), count);
    cout << endl;
    produceReport(withIntAcct.size(), "Checking with interest Account Information",      withIntAcct.at(count));
}
system("pause");
return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T18:36:01+00:00Added an answer on May 21, 2026 at 6:36 pm
    class BankAccount
    class SavingsAccount : public BankAccount
    class CheckingAccount : public BankAccount
    class CheckingWithInterest : public SavingsAccount, public CheckingAccount
    

    This inheritance hierarchy is (probably) incorrect. Right now it looks like this:

     BankAccount       BankAccount
          |                 |
    SavingsAccount   CheckingAccount
          \                 /
          CheckingWithInterest
    

    So, each CheckingWithInterest object actually has two BankAccount base class subobjects: one from its SavingsAccount base class subobject and one from its CheckingAccount base class subobject.

    So, when you try to call a BankAccount member function on a CheckingWithInterest object, e.g.,

    CheckingWithInterest account;
    account.enterAccountData();
    

    the compiler doesn’t know whether you mean the enterAccountData() from the BankAccount that is part of the SavingsAccount base class or you mean the enterAccountData() from the BankAccount that is part of the CheckingAccount base class.

    I’m not sure what, exactly, your requirements are, but if you only want to have a single BankAccount base class subobject, you probably need to use virtual inheritance when you derive CheckingAccount and SavingsAccount from BankAccount, so that the BankAccount subobject is shared between them when they are composed in CheckingWithInterest:

    class BankAccount
    class SavingsAccount : public virtual BankAccount
    class CheckingAccount : public virtual BankAccount
    class CheckingWithInterest : public SavingsAccount, public CheckingAccount
    

    If you really do want there to be two BankAccount base class subobjects, then when you call enterAccountData(), you need to qualify on which base class subobject you want to call the member function:

    account.CheckingAccount::enterAccountData();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive been smashing my head with this for a while. I have 2 completely
I've been using VMWare for a while and am very happy with it, but
I've been using htmldoc for a while, but I've run into some fairly serious
I've been wondering this for a while but since it hasn't come up much
i've been programming a while in D (http://www.digitalmars.com/d/) now. I prefer it to Java
I've been googling for a while now, and can't figure out how to create
I've been looking for a while how to play sound on the iphone, and
I've been trying for a while now to write a unit test for a
I've been using WWF for a while as part of an internal call center
I've been learning python for a while now with some success. I even managed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.