Seeking assistance with my code and the errors I'm encountering - any guidance would be highly valued.
Currently facing an issue with getNextAcountNumber
. I attempted to assign the account ID value, but encountered a problem as it is a private member.
Error 1 error LNK2019: unresolved external symbol "private: int __thiscall Account::getNextAccountNumber(void)const " (?getNextAccountNumber@Account@@ABEHXZ) referenced in function "public: __thiscall Account::Account(class std::basic_string,class::allocator >,double)" (??0Account@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@N@Z) H:\programming\AccountClass\AccountClass.obj AccountClass
H:\programming\AccountClass\Debug\AccountClass.exe : fatal error LNK1120: 1 unresolved externals
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
#include "Account.h"
using namespace std;
int main()
{
Accountacct01;
Accountacct02("Harold M. Ferguson", 2000);
Accountacct03("Elise Janet Simmons", 3500);
Accountacct04("James Holder", 0);
cout << endl << "Account information - initial" << endl;
acct01.displayAccountInfo();// show account information - initial values
acct02.displayAccountInfo();
acct03.displayAccountInfo();
acct04.displayAccountInfo();
acct01.setAccountHolder("Mary A. Tarleton");
acct01.setBalance(542.39);
acct04.setAccountHolder("James Ellis Holder");
acct04.setBalance(1990.75);
cout << endl << "Account information after changes" << endl;
acct01.displayAccountInfo();// show account information after changes
acct02.displayAccountInfo();
acct03.displayAccountInfo();
acct04.displayAccountInfo();
acct01.depositAmount(455);// make deposits
acct02.depositAmount(-19.95);// negative deposit not allowed - set to zero
acct03.depositAmount(4365.27);
acct04.depositAmount(95.63);
cout << endl << "Account information after deposits" << endl;
acct01.displayAccountInfo();// show account information after deposits
acct02.displayAccountInfo();
acct03.displayAccountInfo();
acct04.displayAccountInfo();
acct01.withdrawAmount(37.39);
acct02.withdrawAmount(-475.25);// withdrawal may be positive or negative (absolute value)
acct03.withdrawAmount(0.25);
acct04.withdrawAmount(50.00);
cout << endl << "Account information after withdrawals" << endl;
acct01.displayAccountInfo();// show account information after withdrawals
acct02.displayAccountInfo();
acct03.displayAccountInfo();
acct04.displayAccountInfo();
cout << endl;
system("pause");
return 0;
}
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include "Account.h"
#include <string>
using namespace std;
Account::Account()
{
accountID = getNextAccountNumber();
accountHolder = "no name";
balance = 0;
}
Account::Account(string name, double amount)
{
accountID = getNextAccountNumber();
accountHolder = name;
balance = amount;
}
intAccount::getAccountID()const
{
return accountID;
}
stringAccount::getAccountHolder()const
{
return accountHolder;
}
doubleAccount::getBalance()const
{
return balance;
}
voidAccount::setAccountHolder(string name)
{
accountHolder = name;
}
voidAccount::setBalance(double amt)
{
amt = balance;
}
voidAccount::depositAmount(double amt)
{
if (amt > 0)
{
balance = +amt;
}
else;
{
balance = balance;
}
}
voidAccount::withdrawAmount(double amt)
{
balance = balance - amt;
}
voidAccount::displayAccountInfo()const
{
cout << accountID << accountHolder << balance;
}
#ifndef ACCOUNT_H
#define ACCOUNT_H
#include <string>
using namespace std;
staticintaccountNumber = 100000;// starting value for account#
class Account
{
public:
Account();// default constructor
Account(string name, double amount);// constructor with two parameters
intgetAccountID()const;// ACCESSOR member functions
stringgetAccountHolder()const;// return name of account holder
doublegetBalance()const;// return account balance
voidsetAccountHolder(string name);// MUTATOR member functions
voidsetBalance(double amt);// assign amount to balance
voiddepositAmount(double amt);// add amount to balance
voidwithdrawAmount(double amt);// subtract absolute value of amount from balance
// HELPER member functions
voiddisplayAccountInfo()const;// display account information
private:
intgetNextAccountNumber()const;// get next account# (pre-increment account number)
// private DATA members
intaccountID;// account# identifier
stringaccountHolder;// name of account holder
doublebalance;// account balance
};
// accountID = ++accountNumber
#endif