cout >> Account array
Jul 26, 2013 at 5:16pm UTC
I'm doing a banking code and working on the part where it would print all of the accounts in an array class Account. I'm not really sure how to go about this.
I'll put the header in the code box.
Thanks!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
*/
#ifndef _BANKINGSYSTEM_H
#define _BANKINGSYSTEM_H
#include <iostream>
#include <string>
#include <cstdlib>
//Class Account holds an account ID, passcode,
//first name, last name, and balance. All variables
//are kept private. Access/changes are made through
//public set and get functions.
class Account
{
public :
void SetAccountID(unsigned accountID);
unsigned GetAccountID();
void SetPasscode(unsigned passcode);
unsigned GetPasscode();
void SetFirstName(const std::string& firstName);
std::string GetFirstName();
void SetLastName(const std::string& lastName);
std::string GetLastName();
void SetBalance(double balance);
double GetBalance();
private :
unsigned accountID_;
unsigned passcode_;
std::string firstName_;
std::string lastName_;
double balance_;
};
//Assume a max of 100 accounts.
const size_t MAX_NUM_ACCOUNTS = 100;
//Class BankingSystem uses an array of Account.
//You can create, delete, print, deposit, and withdraw.
class BankingSystem
{
public :
BankingSystem();
void CreateAccount();
void DeleteAccount();
void PrintAccounts();
void Deposit();
void Withdraw();
private :
Account accounts_[MAX_NUM_ACCOUNTS];
size_t current_num_accounts_;
//Use these auxiliary functions if you want.
//See bankingSystem.cpp for more info.
size_t FindAccount(unsigned accountID);
bool MatchPasscode(unsigned passcode, size_t index);
};
Topic archived. No new replies allowed.