ThatScriptGuy
10-18-2006, 05:36 PM
I've been doing great in my programming class for awhile now, but finally I'm stuck and forced to come ask for help again :)
// lab12.cpp
#include <iostream>
#include <string>
#include "Checkbook.h"
#include <iomanip>
#include <fstream>
using namespace std;
void printhead();
void printmenu();
void processmenu(char menu);
void balance();
void invalidinput();
int main()
{
Checkbook acct; // Object
system("clear"); //Clear the screen on first menu to make it better looking
printhead(); //Function to print the menu and receive menu input
//Testing...
acct.Deposit(500);
cout << acct.CurrentBalance();
return 0;
}
void printhead()
{
cout << "****************************************" << endl;
cout << "* Personal Checkbook Balancing Program *" << endl;
cout << "****************************************" << endl << endl;
cout << "Please select a menu item by typing a character" << endl
<< "in parentheses and pressing the return key." << endl << endl;
printmenu();
}
void printmenu()
{
char menu;
cout << "--- MENU ---" << endl
<< "(B) Balance" << endl
<< "(D) Deposit" << endl
<< "(W) Withdrawal" << endl
<< "(S) Service Charge" << endl
<< "(Q) Quit" << endl << endl;
cout << "Your Choice ===> ";
cin >> menu;
processmenu(menu); //Here we call the function to process the user input
}
void processmenu(char menu)
{
if (menu == 'B' || menu == 'b')
balance();
else if (menu == 'D' || menu == 'd')
cout << "Deposit\n";
else if (menu == 'W' || menu == 'w')
cout << "Withdrawal\n";
else if (menu == 'S' || menu == 's')
cout << "Service Charge\n";
else if (menu == 'Q' || menu == 'q')
cout << "Quitting\n";
else //Invalid choice - Throw error and repeat menu
invalidinput();
}
void balance()
{
// cout << acct.CurrentBalance();
}
void invalidinput()
{
cout << endl;
cout << "[0;31;40m"; //Change font color to red for more visibility
cout << "You have entered an invalid menu selection!\n\n";
cout << "[0;37;40m"; //Change font color back to white
printmenu(); //Print the menu again with error still visible
}
In the balance function, if I uncomment the cout line, I can't compile with the following error:
error: request for member `CurrentBalance' in `acct', which is
of non-aggregate type `int ()(const char*) throw ()'
I have no idea what this means...Obviously it's because I'm calling that from within the function - Up towards the top, where I call it, it works perfectly fine..but when called from within the balance function, it just won't compile....What am I missing here???
Thanks,
Kevin
// lab12.cpp
#include <iostream>
#include <string>
#include "Checkbook.h"
#include <iomanip>
#include <fstream>
using namespace std;
void printhead();
void printmenu();
void processmenu(char menu);
void balance();
void invalidinput();
int main()
{
Checkbook acct; // Object
system("clear"); //Clear the screen on first menu to make it better looking
printhead(); //Function to print the menu and receive menu input
//Testing...
acct.Deposit(500);
cout << acct.CurrentBalance();
return 0;
}
void printhead()
{
cout << "****************************************" << endl;
cout << "* Personal Checkbook Balancing Program *" << endl;
cout << "****************************************" << endl << endl;
cout << "Please select a menu item by typing a character" << endl
<< "in parentheses and pressing the return key." << endl << endl;
printmenu();
}
void printmenu()
{
char menu;
cout << "--- MENU ---" << endl
<< "(B) Balance" << endl
<< "(D) Deposit" << endl
<< "(W) Withdrawal" << endl
<< "(S) Service Charge" << endl
<< "(Q) Quit" << endl << endl;
cout << "Your Choice ===> ";
cin >> menu;
processmenu(menu); //Here we call the function to process the user input
}
void processmenu(char menu)
{
if (menu == 'B' || menu == 'b')
balance();
else if (menu == 'D' || menu == 'd')
cout << "Deposit\n";
else if (menu == 'W' || menu == 'w')
cout << "Withdrawal\n";
else if (menu == 'S' || menu == 's')
cout << "Service Charge\n";
else if (menu == 'Q' || menu == 'q')
cout << "Quitting\n";
else //Invalid choice - Throw error and repeat menu
invalidinput();
}
void balance()
{
// cout << acct.CurrentBalance();
}
void invalidinput()
{
cout << endl;
cout << "[0;31;40m"; //Change font color to red for more visibility
cout << "You have entered an invalid menu selection!\n\n";
cout << "[0;37;40m"; //Change font color back to white
printmenu(); //Print the menu again with error still visible
}
In the balance function, if I uncomment the cout line, I can't compile with the following error:
error: request for member `CurrentBalance' in `acct', which is
of non-aggregate type `int ()(const char*) throw ()'
I have no idea what this means...Obviously it's because I'm calling that from within the function - Up towards the top, where I call it, it works perfectly fine..but when called from within the balance function, it just won't compile....What am I missing here???
Thanks,
Kevin
