I have been looking around on the forums, and most people say this is called when a function does not have a body but I have checked and all have a body. I am not sure where to continue from here....
It is split between the header where the prototypes are located a separate .cpp file where it defines all the functions, and finally the main one.
#pragma once
#include<string>
usingnamespace std;
class Account
{
private:
int accountId;
double balance;
double annualInterestRate;
public:
Account();
Account(int id, double bal, double interest);
void setAccountId(int x);
// Function to set accountId based on passed parameter.
// Postcondition: accountId = x;
void setBalance(double x);
// Function to set balance based on passed parameter.
// Postcondition: balance = x;
void setInterest(double x);
// Function to set annualInterestRate based on passed parameter.
// Postcondition: annualInterestRate = x;
int getAccountId();
// Function to set accountId.
// Postcondition: accountId is returned.
double getBalance();
// Function to set balance.
// Postcondition: balance is returned.
double getInterest();
// Function to set annualInterestRate.
// Postcondition: annualInterestRate is returned.
double getMonthlyInterestRate();
// Function to calculate the monthly interest rate.
// Postcondition: Monthly interest rate is calculated and returned.
double getMonthlyInterest();
// Function to calculate the amount that would be earned through monthly interest.
// Postcondition: Amount that will be earned through monthly interest is calculated and returned.
bool withdraw(double amount);
// Function to reduce the account's current balance by the passed parameter, but only if the balance
// is greater than the passed in parameter. If successful, return true, otherwise return false.
// Postcondition: if (balance > amount) balance = balance - amount and return true;
// otherwise return false;
void deposit(double amount);
// Function to increase the account's current balance by the passed parameter.
// Postcondition: balance = balance + amount;
};
#include<iostream>
#include<string>
#include"account.h"
usingnamespace std;
int EnterAccountNumber();
void menuSelecton(int _accountId);
int main()
{ //Set variables up
int UsersId = -3;// Make sure it isn't a usable account
UsersId=EnterAccountNumber();
void menuSelection(int UsersId);
}
int EnterAccountNumber()
{
/*//////////////////////////////////////////////////////////////////////
//
// Function: EnterAccountNumber
//
// Description:
// It will ask the user what is their account number and return
//
// Parameters:
//
//
// Returns:
// Their account number
//
///////////////////////////////////////////////////////////////////////
*/
int n = 0;
cout << "Please enter an account number from 0 - 9 " << endl;
cin >> n ;
return n;
};
void menuSelecton(int _accountId)
{
/*//////////////////////////////////////////////////////////////////////
//
// Function: MenuSelection
//
// Description:
// Acts as the menu for the user to check their account balance monthy rates withdraw and deposit
//
// Parameters:
// account ID which is will use it as the index for the accoutn array
//
// Returns:
// void
//
*///////////////////////////////////////////////////////////////////////
Account accounts[10];
accounts[_accountId];
/*//////////////////////////////////////////////////////////////////////
//
// Function: menuSelection
//
// Description:
// This lets the user select their function for their spesific account
//
//
// Parameters:
//
//
// Returns:
// Void
//
///////////////////////////////////////////////////////////////////////
*/
// You might need to add the account as a pass by
cout << "Enter 1 to make a deposit" << endl <<
"Enter 2 to make a withdrawl" << endl <<
"Enter 3 to check Balance" << endl <<
"Enter 4 to check intrest rate" << endl <<
"Enter 5 to display account summary" << endl<<
"Enter -1 to return to the main menu:"<<endl;
int Selection;
double deposit = 0.0;
double withdrawl = 0.0;
cin >> Selection;
switch (Selection)
{
case 1:
//Function for deposit
cout << "How much would you like to deposit ";
cin >> deposit;
accounts[_accountId].deposit(deposit);
cout << endl << "Thank you a total of " << deposit << " has been depositied " << endl <<
"Your total is now" << accounts[_accountId].getBalance() << endl;
break;
case 2:
// Function for withdrawl
cout << "How much would you like to withdraw? ";
cin >> withdrawl;
if (accounts[_accountId].withdraw(withdrawl) == false)
{
cout << "Sorry you do not have enough please try again later";
}
else
{
cout << "You have withdrawn " << withdrawl << endl <<
"You now have " << accounts[_accountId].getBalance() << endl <<
"come again!" << endl;
}
break;
case 3:
//Function to check balance
cout << "Your current balance is " << accounts[_accountId].getBalance()
<< endl << "thank you have a great day!";
break;
case 4:
// Function to check the Monthly intrest rates and yearly
cout << "Your Monthly intrest is " << accounts[_accountId].getInterest() << endl <<
"Your yearly intrest is " << accounts[_accountId].getMonthlyInterestRate() << endl;
break;
case 5:
// Check ID, Balance,, Monthly intrest rate and monthly amount
cout << "Your account ID is " << accounts[_accountId].getAccountId() << endl <<
"Your monthly intrest rate is " << accounts[_accountId].getMonthlyInterestRate() << endl <<
" your monthly intrest for this month is " << accounts[_accountId].getMonthlyInterest() << endl;
break;
case -1:
break;
default:
//Add same program back into here
cout << "Invalid Seleciton..." << endl << endl << endl;
};
}
Just telling us a couple of error numbers isn't very helpful. Your linker will be giving you detailed information on which symbols it thinks are undefined, and which object files are trying to use those symbols. Why keep that information secret from us?
EDIT:
What is line 58 of your main cpp file supposed to be doing? Because it isn't doing anything.
line 58 is supposed to tell the program what index of the array to reference
How do you mean? Reference where?
That line does nothing. accounts[_accountId] is just a single object. It's the equivalent of having:
1 2
Account myAccount;
myAccount;
That link error is telling you that the linker can't find your main function. This is probably because you've made a mistake in setting up your project in Visual Studio.
I took out that line after I realized what you were saying. I found the issue to be in the other Cpp file that doesn't include the main.I re did the program, but still haven't found the issue.
I made another Project copy and pasted the .h file, no error, then the .cpp file that didn't have a main but just the definitions and that got me the error
In case anyone ever stumbles upon this. I had it for a win32 project and everything is set up correctly, My professor just let me do it in a blank project