'myAccount' : undeclared identifier?
Jul 31, 2009 at 6:38pm UTC
How I would I define myAccount usefully here? I thought I already did...
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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
//classes, functions, prototypes
const int SIZE = 100;
//return for each function
class customerInfo
{
char name[SIZE];
float amount;
//enum, functions other than main
//customerInfo();
//~customerInfo();
};
//customerInfo *myAccount = new customerInfo[SIZE]; declare customer array (myaccount pointing to first address)
// myAccount++ to next. INCLUDE delete [] myAccount;
void menuCust ()
{
char choice;
bool terminate = false ;
while (!terminate)
{
cout << "Customer Services: Please enter an option\n"
<< "1) Balance Inquiry\n"
<< "2) Deposit Funds\n"
<< "3) Withdraw Funds\n"
<< "4) Transfer Funds to another account\n"
<< "5) Anything else that you want to add\n"
<< "6) Quit the application\n\n" ;
cin >> choice;
switch (choice)
{
case '1' :
break ;
case '2' :
break ;
case '3' :
break ;
case '4' :
break ;
case '5' :
cout << "You have chosen to quit. We appreciate your business.\n\n" ;
terminate = true ;
break ;
default :
cout << "You have entered an invalid option, please try again\n" ;
break ;
}
}
delete [] myAccount;
exit(1);
}
void menuBank ()
{
char choice;
bool terminate = false ;
while (!terminate)
{
cout << "Please enter an option: \n"
//<< "1) Everything in the Customer Interface, plus
<< "1) Add a new Customer to the Bank\n"
<< "2) Delete a Customer from the Bank\n"
<< "3) Search for Customer Record\n"
<< "4) Quit the application\n\n" ;
cin >> choice;
switch (choice)
{
case '1' :
break ;
case '2' :
break ;
case '3' :
break ;
case '4' :
cout << "You have chosen to quit. We appreciate your business.\n\n" ;
terminate = true ;
break ;
default :
cout << "You have entered an invalid option, please try again\n" ;
break ;
}
}
delete [] myAccount;
exit(1);
}
void menuSuper ()
{
char choice;
bool terminate = false ;
while (!terminate)
{
cout << "Supervising: Please enter an option\n"
//a.Everything in Bank Teller Interface, plus
<< "1) List Total Number of Customers in Bank\n"
<< "2) List Total Amount of Money in the Bank\n"
<< "3) List Total Deposits in a Day\n"
<< "4) List Total Withdrawals in a Day\n"
<< "5) View detailed log of all transactions\n"
<< "6) Quit the application\n\n" ;
cin >> choice;
switch (choice)
{
case '1' :
break ;
case '2' :
break ;
case '3' :
break ;
case '4' :
break ;
case '5' :
break ;
case '6' :
cout << "You have chosen to quit. We appreciate your business.\n\n" ;
terminate = true ;
break ;
default :
cout << "You have entered an invalid option, please try again\n" ;
break ;
}
}
delete [] myAccount;
exit(1);
}
int main ()
{
char choice;
bool terminate = false ;
customerInfo *myAccount = new customerInfo[SIZE]; //declare customer array (myaccount pointing to first address)
while (!terminate)
{
cout << "WELCOME TO SO-AND-SO BANK!\n\n" << "Please enter an option, are you a:\n\n"
<< "A)Customer\n"
<< "B)Bank Employee\n"
<< "C)Bank Supervisor\n"
<< "D)Quit the application\n\n" ;
cin >> choice;
switch (choice)
{
case 'a' :
case 'A' :
menuCust();
break ;
case 'b' :
case 'B' :
menuBank();
break ;
case 'c' :
case 'C' :
menuSuper();
break ;
case 'd' :
case 'D' :
cout << "You have chosen to quit. We appreciate your business.\n\n" ;
terminate = true ;
break ;
default :
cout << "You have entered an invalid option, please try again\n" ;
break ;
}
}
/*
cout << "How many numbers would you like to type? ";
cin >> i;
p= new (nothrow) int[i];
if (p == 0)
cout << "Error: memory could not be allocated";
else
{
for (n=0; n<i; n++)
{
cout << "Enter number: ";
cin >> p[n];
}
cout << "You have entered: ";
for (n=0; n<i; n++)
cout << p[n] << ", ";
delete[] p;
}
//above
*/
delete [] myAccount;
return 0;
}
Jul 31, 2009 at 7:45pm UTC
You've declared myAccount as a variable local to main() only. If you want other functions
to use it, you will need to pass the variable as a parameter to those functions.
Topic archived. No new replies allowed.