I am working on one of my first c++ projects. I was provided with a .h file and had to write a .cpp file, but it won't compile. I keep getting the error message:
g++ -o proj1 proj1.cpp proj1.h /tmp/ccsK4pOL.o: In function menuMain()':
proj1.cpp:(.text+0x807): undefined reference todisplayBalance(float)' proj1.cpp:(.text+0x81b): undefined reference to deposit(float&)'
proj1.cpp:(.text+0x82f): undefined reference towithdraw(float&)' collect2: ld returned 1 exit status
/*
Name: menuStart()
PreCondition: None
PostCondition: Returns the selected option (1, 2, or 3)
*/
int menuStart();
/*
Name: menuMain()
PreCondition: The user input has either been loaded from file or entered by user
PostCondition: Returns the selected option (1, 2, 3, 4, or 5)
*/
int menuMain();
/*
Name: displayAccountDetails
PreCondition: Relevant data (fName, lName, age, accountBalance) has been loaded/entered
PostCondition: None (void)
*/
void displayAccountDetails(string fName, string lName, int age, float accountBalance);
/*
Name: displayBalance
PreCondition: Relevant data (accountBalance) has been loaded/entered
PostCondition: None (void)
*/
void displayBalance(float accountBalance);
/*
Name: deposit
PreCondition: Variable accountBalance is passed-by-reference
PostCondition: accountBalance is permanently changed via pass-by-reference
*/
void deposit(float &accountBalance);
/*
Name: withdraw
PreCondition: Variable accountBalance is passed-by-reference
PostCondition: accountBalance is permanently changed via pass-by-reference
*/
void withdraw(float &accountBalance);
#endif
and this is my code - any help debugging would be appreciated, as I am very new to this.
int menuStart() //has user load txt file, enter info or exit
{
string firstName;
string lastName;
int userAge;
float balance;
int userIn;
cout << "Welcome to the UMBC ATM" << endl;
cout << "Choose from below: " << endl;
cout << "1. Load a User Profile from File" << endl;
cout << "2. Enter a new User Profile" << endl;
cout << "3. Exit" << endl;
cout << "Enter your choice: " << endl;
cin >> userIn;
//make sure inupt is valid
while (userIn < 1 || userIn > 3)
{
string save;
cout << "Would you like to save your account information?: " << endl;
cout << "yes or no" << endl;
cin >> save;
while ((save != "yes") || (save != "no"))
{
cout << "INVALID. Enter yes or no." << endl;
menuMain();
}
if (save == "yes") //save info to text file
//code to save info to text file
ofstream profileTxt;
profileTxt.open("proj1.txt");
profileTxt << firstName << lastName << userAge << balance << endl;
profileTxt.close();
cout << "Thank you for using the UMBC ATM";