A simple C++ implementation of a bank account management system demonstrating object-oriented programming principles including inheritance and polymorphism.
This project implements a basic banking system with features for depositing, withdrawing, and managing account information. It uses an abstract base class BankAccount with a concrete implementation in MyBankAccount to showcase inheritance and virtual functions in C++.
- Deposit Money: Add funds to your account (with validation for positive amounts)
- Withdraw Money: Remove funds from your account with balance verification
- View Account Information: Display current account details including name and balance
- Change PIN: Update your account PIN for security
- User Authentication: Simple PIN-based authentication for account operations
main.cpp- Contains all source code including the abstract base class, derived class, and main program logicrun.sh- Build and run script for the project
bash run.shg++ main.cpp -o a.exe
.\a.exeOr manually:
g++ main.cpp -o a.exe
./a.exe-
Start the program and enter your credentials:
- Name: Ngong (default account name)
- PIN: p (default account PIN)
-
Select an option from the menu:
- 1) Deposit - Enter amount to add to your account
- 2) Withdrawal - Enter amount to withdraw from your account
- 3) See Information - View your account details
- 4) Change Pin - Update your PIN
- 0) Exit - Exit the program
- Name: Ngong
- PIN: p
- Initial Balance: 0
- Public Members:
name: Account holder's namepin: Account PIN
- Private Members:
amount: Account balance
- Virtual Methods:
deposit(): Add funds to accountwithdraw(): Remove funds from accountdisplayInfo(): Show account informationchangePin(): Update account PIN
Implements all virtual methods from the base class with the following business logic:
- Validates user credentials before any operation
- Ensures deposit and withdrawal amounts are positive
- Checks for sufficient balance before withdrawal
- Updates PIN only when old PIN matches
- Deposit: Amount must be greater than 0
- Withdrawal: Amount must be greater than 0 and cannot exceed current balance
- All Operations: Name and PIN must match account credentials
- "You are too poor" - Attempt to deposit or withdraw negative/zero amount
- "User name and pin code do not match" - Invalid credentials
- "Insufficient Balance" - Attempt to withdraw more than available balance
- C++ compiler (GCC/G++ recommended)
- Standard C++ library support
- This is a basic implementation for educational purposes
- Uses simple string comparison for authentication (not secure for production)
- Balance is stored as an integer (assumes currency in whole units)
- Session-based: Changes persist only during program execution