Implement a class to represent a bank account with methods to deposit, withdraw, and check balance.
HardProblem Statement
Implement a class to represent a bank account with methods to deposit, withdraw, and check balance.
Sample Input
BankAccount account(100); account.deposit(50); account.withdraw(30);
Sample Output
Current balance: 120
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
#include <iostream>
class BankAccount {
private:
double balance;
public:
BankAccount(double initialBalance);
void deposit(double amount);
void withdraw(double amount);
double getBalance();
};
int main() {
// Logic to demonstrate BankAccount functionality
return 0;
}
Input
BankAccount account(100); account.deposit(50); account.withdraw(30);
Expected Output
Current balance: 120