Build a Secure BankAccount Class

Hard Encapsulation, Access Specifiers & The this Pointer PRO
🔒 Login to Unlock

Problem Statement

Combine the concepts! Create a `BankAccount` with private `balance` and `password`. The constructor sets both. `deposit(int amt)` adds securely. `withdraw(int amt, string pwd)` checks the password and balance, printing ‘Withdrawn’ or ‘Auth Failed’ / ‘Insufficient’. Read `init_bal pass dep_amt pass_attempt with_amt`, execute the actions, and print the final balance.

Input Format

int string int string int

Output Format

Print action logs and 'Final Balance: [val]'.

Constraints

Deposit and withdrawal > 0.

Sample Input

1000 mypass 500 mypass 200

Sample Output

Deposited
Withdrawn
Final Balance: 1300

Explanation

A complete scenario combining data hiding, authentication via secure setters/getters, and object-oriented validation logic.

Starter Code

#include <iostream>
#include <string>

class BankAccount {
    // Implement the secured logic
};

int main() {
    // Read sequence and drive the BankAccount API
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used