// Member-function definitions for class Account.
#include <iostream>
#include "Account.h" // include definition of class Account
usingnamespace std;
// Account constructor initializes data member balance
Account::Account( int initialBalance )
{
balance = 0; // assume that the balance begins at 0
// if initialBalance is greater than 0, set this value as the
// balance of the Account; otherwise, balance remains 0
if ( initialBalance > 0 )
balance = initialBalance;
// if initialBalance is negative, print error message
if ( initialBalance < 0 )
cout << "Error: Initial balance cannot be negative.\n" << endl;
} // end Account constructor
// credit (add) an amount to the account balance
void Account::credit( int amount )
{
balance = balance + amount; // add amount to balance
} // end function credit
// debit (subtract) an amount from the account balance
void Account::debit( int amount )
{
if ( amount > balance ) // debit amount exceeds balance
cout << "Debit amount exceeded account balance.\n" << endl;
if ( amount <= balance ) // debit amount does not exceed balance
balance = balance - amount;
} // end function debit
// return the account balance
int main ()
{
Account accountBalance1 ( 50 );
Account accountBalance2 ( 25 );
cout << "New balance for Account 1 is: "
<< accountBalance1.getBalance()
<< "\n\n New balance for Account 2 is: "
<< accountBalance2.getBalance()
<<endl;
system ("pause");
1>------ Build started: Project: Account, Configuration: Debug Win32 ------
1> Account.cpp
1>Account.obj : error LNK2019: unresolved external symbol "public: int __thiscall Account::getBalance(void)" (?getBalance@Account@@QAEHXZ) referenced in function _main
1>C:\Users\documents\visual studio 2010\Projects\Account\Debug\Account.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
If it helps any --- I have already tried setting it to a console type file.