I'm working on a project for school were I need to create a simple banking system.(Acct creation, withdraws, deposits, simple processes like that) My code is pretty much finished but I'm having trouble with the acct. creation. After the user enters the name and int deposit the programs proceeds to close out. This of course happens too when any other process is chosen because all other options are based on the acct creation. I'm new to programing and im sure the mistake is right in front of my face but any thoughts on the matter would help. Thanks.
void Banking::createNewAccount()
{
srand(time(NULL)); // Seed random generator with time initialized to NULL
char acctChoice; // choice for the account type
float initCheckDeposit = 0; // The initial deposit for checking account
float initSaveDeposit = 0; // The initial deposit for saving account
switch(acctChoice)
{
case 'A':
system("cls");
cout << "\t\t -=[ New Checking Account ]=- \n" << endl;
cout << "Name of the main holder to be on the account: ";
getline(cin, acctName);
cout << "Initial deposit amount: $";
cin >> initCheckDeposit;
if(!checkFile)
fatal("[!!] Fatal Error 251: Miscommunication with server\n");
for(int i = 0; i < 12; i++)
{
acctNumber[i] = (rand() % 10); // Build a random checking account number
}
class Banking
{
private:
string acctName; // Name on the account
int acctNumber[13]; // Account number
float acctBalance; // Amount in the account
public:
void getAcctInfo(); // Get name on account for displaying relevant information
void createNewAccount(); // Create a new account and assign it a random account number
// void transferFunds(); // Transfer funds checking <--> savings, passing amount as the argument, saving for later day
void invalid(char *); // If an invalid option is chosen
char menu(); // Print the main menu for the user.
void fatal(char *);
Banking();
};
#endif
Skillless is mistaken you're right to #include "Bank Class.h" instead of "Bank Class.cpp". The linker links it all up and it works. Also, that would be a compile error not a run-time error so you would have known about that before even running the program.
As far as your problem, I think you actually aren't having a problem. You call the menu(), which then calls createAccount(), and then you create your account.. createAccount() exits, and then menu() exits and then main() exits and the program ends. There's no action in Banking::menu() after it calls createAccount().
I'm not using a compiler to check any of this but just looking through your code it looks like it'll execute just as you said: the user enters the account information and the program exits. So I'm guessing there isn't actually a problem with your code.
If you want something to happen after the account creation, then you'll want to put whatever you want probably after the switch block in Banking::menu() or maybe before the break; in the switch block after the call to createAccount().
I hope I've made sense and not led you astray.
In other news, when posting code segments please outline it with [code] tags :).