이 코드는 입금, 잔액 확인 및 계좌에서 돈을 인출하는 고객을 다루는 "가상 ATM 기계"프로그램의 코드입니다. 내가 돈을 입금하면, 그것이 입금됩니다 것을 표시합니다 ..하지만 ... 여기에 내가 내 문제를 언급하기 전에 코드를 간다 :C++ 값이 필요에 따라 저장되지 않았습니다.
double bankAccount::deposit()
{
bankAccount b;
double amt;
system("cls");
cout << " ----------------------------------------------------------------------- \n";
cout << "| Customer Menu | \n";
cout << " ----------------- ----------------- ----------------- ----------------- \n";
cout << "\n\nYOUR CURRENT BALANCE: " << balance << endl;
cout << "\nEnter amount to deposit: ";
cin >> amt;
balance = (balance + amt);
cout << "\nAmount depositted successfully!" << endl;
cout <<"\nYOUR CURRENT BALANCE: " << balance;
getch();
customer_actions();
return balance;
}
"customer_actions()"고객을위한 메인 메뉴 때이되고 해당 화면으로 돌아가서 잔액을 확인하는 옵션을 선택하면 ZERO로 표시됩니다. 즉, 값이 이전 함수에서 업데이트되지 않았다는 의미입니다.
#ifndef bank
#define bank
using namespace std;
class bankAccount
{
public:
int accNo;
int password;
double balance;
double withdrawamt;
double depositamt;
char name[20];
char address[40];
char username[10];
public:
double checkbalance();
double deposit();
double withdraw();
public:
bankAccount()
{
balance = 0; // Is this the reason?
}
};
#endif
내가 생각하고, 프로그램이 다른 하나의 메뉴에서 전환, 값이 다시-ED를 얻을 다음은 클래스 파일로 구성 내 헤더 파일입니다. 제안 사항, 소중한 사람들? 사전에
감사합니다!
CUSTOMER_ACTIONS : (내가 볼 수있는 것과)
int customer_actions()
{
bankAccount b;
int cust_selection;
system("cls");
cout << " ----------------------------------------------------------------------- \n";
cout << "| Customer Menu | \n";
cout << " ----------------- ----------------- ----------------- ----------------- \n";
cout << " Please Select option to continue: \n" << endl << endl;
cout << "1) Check balance : Press 1" << endl;
cout << "2) Withdraw Cash : Press 2" << endl;
cout << "3) Deposit Cash : Press 3" << endl;
cout << "4) Transfer Cash : Press 4" << endl;
cout << "5) Return home : Press 5" << endl;
cout << "\nEnter option: ";
cin >> cust_selection;
switch(cust_selection)
{
case 1: b.checkbalance(); break;
case 2: b.withdraw(); break;
case 3: b.deposit(); break;
case 4: break;
case 5: main(); break;
}
}
여기 메뉴가 표시되지 않습니다. –
아마도 bankAccount 인스턴스를 계속해서 다시 만들고 있기 때문에 ... –
customer_actions()가 무엇인지 알아야합니다. – ApplePie