Here is my code for the program. which I'm trying to complie...I just started testing it and was going through it step by step...but the first function whichI started testing is getAccountNumbers, but there are some issues with it, here's the code, it has Person file included in it, it just takes the detais of the person.
#include<cstdlib>
#include<string>
#include<time.h>
#include"Person.h"
#include<iostream>
using namespace std;
typedef Person* PersonPtr;
class BankAccount{
public:
//friend ostream& operator << (ostream& aOutput, const BankAccount& aBankAccount);
//friend istream& operator >> (istream& aInput, BankAccount& aBankAccount);
//friend bool operator == (const BankAccount& aBankAccount1, const BankAccount& aBankAccount2);
BankAccount();
BankAccount(const Person& aPerson);
/** double withdrawal(double aAmount);
double deposit(double aAmount);*/
size_t getAccountNumber() const;
/**void setBalance(double aBalance);
double getBalance() const;
void setAccountOwner(const Person& aPerson);
Person getAccountOwner() const;
bool sufficientFundsToWithdrawal(double aAmount) const;*/
private:
PersonPtr mPerson;
//mAmount;
double mBalance;
size_t mAccountNumber;
};
//#endif
int main() {
//BankAccount ba;
Person p;
cout <<"running";
getAccountNumber();
//cin >> ba;
//cout << ba;
return 0;
}
/**
ostream& operator << (ostream& aOutput, const BankAccount& aBankAccount){
cout << "A new account with account number";
aOutput << aBankAccount.mAccountNumber << endl;
cout << "has been created for";
aOutput << aBankAccount.mPerson << endl;
return aOutput;
}
istream& operator >> (istream &aInput, BankAccount& aBankAccount){
cout << "Please type the intitial balance for account number: " << aBankAccount.mAccountNumber << endl;
aInput >> aBankAccount.mBalance;
aInput >> aBank.mPerson;
cout << "type the first name\n;
aInput >> aBankAccount.mFName;
cout << "type the last name\n;
aInput >> aBankAccount.mLName;
cout << "Type the address\n";
aInput >> aBankAccount.mAddress;
cout << "type the name of the state\n";
aInput >> aBankAccount.mState;
cout << "type the name of the city\n";
aInput >> aBankAccount.mCity;
cout << "type the zip code\n";
aInput >> aBankAccount.mZip;
return aInput;
}
bool operator == (const BankAccount& aBankAccount1, const BankAccount& aBankAccount2){
return(aBankAccount1.mPerson == aBankAccount2.mPerson &&
aBankAccount1.mBalance == aBankAccount2.mBalance &&
aBankAccount1.mAccountNumber == aBankAccount2.mAccountNumber);
}
BankAccount::BankAccount(){
mPerson = new Person;
mBalance = 5.00;
mAccountNumber = getAccountNumber();
}
BankAccount::BankAccount(const Person &aPerson):mPerson( new Person), mBalance(5.00),mAccountNumber(getAccountNumber()){
}
void setAccountOwner (const Person& aPerson){
mPerson = new Person;
}
Person getAccountOwner () const{
return mPerson;
}
double withdrawal (double aAmount){
double newBalance = Balance - aAmount;
setBalance(newBalance);
getBalance();
//return aBalance;
}
double deposit (double aAmount){
double newBalance = newBalance + aAmount;
aBankAccount.setBalance(newBalance);
aBankAccount.getBalance ();
}*/
size_t getAccountNumber () const {
srand(static_cast<unsigned int>(time(NULL)));
mAccountNumber = rand();
return mAccountNumber;
}/**
void setBalance (double aBalance) {
mBalance = aBalance;
}
double getBalance () const{
return mBalance;
}
bool sufficientFundsToWithdrawal (double aAmount) const {
if((aAmount - aBalance) > 5){
return true;
}
else {
return false;
}
}
*/
I'm trying to test only the getAccountNumber function here . But the compiler giives me error like this:
1>c:\users\sherry\documents\visual studio 2008\projects\testing\testing\bankaccount.cpp(37) : error C3861: 'getAccountNumber': identifier not found
1>c:\users\sherry\documents\visual studio 2008\projects\testing\testing\bankaccount.cpp(105) : error C2270: 'getAccountNumber' : modifiers not allowed on nonmember functions
1>c:\users\sherry\documents\visual studio 2008\projects\testing\testing\bankaccount.cpp(107) : error C2065: 'mAccountNumber' : undeclared identifier
1>c:\users\sherry\documents\visual studio 2008\projects\testing\testing\bankaccount.cpp(108) : error C2065: 'mAccountNumber' : undeclared identifier
Please help me figure out how to handle that size_t type an wy its complainig that mAccountNumber identifier is undeclared.