Untitled
unknown
plain_text
10 months ago
628 B
8
Indexable
#include <iostream>
using namespace std;
class BankAccount {
private:
int accountNumber;
double balance;
public:
BankAccount() : accountNumber(0), balance(0) {}
BankAccount(int acc, double bal) : accountNumber(acc), balance(bal) {}
void deposit(double amt) { balance += amt; }
void withdraw(double amt) { if (amt <= balance) balance -= amt; else cout << "Insufficient balance\n"; }
void display() { cout << "Acc No: " << accountNumber << ", Balance: " << balance << endl; }
};
int main() {
BankAccount acc(101, 500);
acc.deposit(200);
acc.withdraw(100);
acc.display();
return 0;
}Editor is loading...
Leave a Comment