I'm writing a program called BankAccount that uses a class called BankAccount. I'm pretty sure I have everything right that I want to have in it, but when I try to compile it, it comes up with 13 errors. I'm pretty sure they all have to do with the first error that says : "Error C2065: 'BankAccount' : Undeclared identifier"
I'm going to put in both my .h file and my tester file so that maybe you can help me see what is wrong with it? And why it's not recognizing the class that I made. Thanks so much
Header file (BankAccount.h)
Code:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;
class BankAccount
{
private:
int acctNumber;
string name;
double balance;
public:
BankAccount();
BankAccount(int, string, double);
void setAcctNumber(int);
void setName(string);
void setBalance(double);
int getAcctNumber();
string getName();
double getBalance();
void deposit(double);
void withdraw(double);
void displayData();
};
BankAccount::BankAccount()
{
acctNumber = 0;
name = "unknown";
balance = 0.0;
}
BankAccount::BankAccount(int aNum, string aName, double amount)
{
acctNumber = aNum;
name = aName;
balance = amount;
}
void BankAccount::setAcctNumber(int aNum)
{
acctNumber = aNum;
}
void BankAccount::setName(string aName)
{
name = aName;
}
void BankAccount::setBalance(double amount)
{
balance = amount;
}
int BankAccount::getAcctNumber()
{
return acctNumber;
}
string BankAccount::getName()
{
return name;
}
double BankAccount::getBalance()
{
return balance;
}
void BankAccount::deposit(double amount)
{
balance += amount;
}
void BankAccount::withdraw(double amount)
{
balance -= amount;
}
void BankAccount::displayData();
{
cout << "Your account number is " << acctNum << endl;
cout << "Your name is " << name << endl;
cout << "Your balance is " << balance << endl;
}
Tester file (Bank.cpp)
Code:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;
void displayMenu();
int main()
{
BankAccount studentAccount;
double amount = 0.0;
int choice = 0;
int iValue = 0;
string name = "Millionare";
do {
displayMenu();
cin >> choice;
cout << endl;
switch (choice)
{
case 1 : do
{
cout<< "Enter amount: (greater than 0) " ;
cin >> amount;
studentAccount.deposit(amount);
break;
}
while (amount <= 0);
case 2 : do
{
cout << "Enter amount: (greater than 0) " ;
cin >> amount;
studentAccount.withdraw(amount);
break;
}
while (amount <= 0);
case 3 : cout << "Enter the name: ";
cin.ignore();
getline(cin,name);
studentAccount.setName(name);
break;
case 4 : cout << "Enter the number: ";
cin >> iValue;
studentAccount.setAcctNumber(iValue);
break;
case 5 : studentAccount.displayData();
break;
case 6 : cout << "\nBank is closed.\n" ;
break;
default : cout << "Invalid entry.";
}
}while (choice != 6);
return 0;
}
void displayMenu()
{
cout << "\n Welcome to your bank \n\n";
cout << "1. Make a deposit\n";
cout << "2. Make a withdrawal\n";
cout << "3. Set the account name\n";
cout << "4. Set the account number\n";
cout << "5. Display account information\n";
cout << "6. Exit\n\n";
cout << "Please enter your choice: ";
}