Build a BankOverdraftException Workflow

Hard Exception Handling in OOP PRO
🔒 Login to Unlock

Problem Statement

Combine the concepts! Create a custom `BankOverdraftException` inheriting from `std::exception` that stores an `int deficit`. Override `what()` to return “Overdraft”. In `BankAccount::withdraw(amount)`, if `amount > balance`, throw the custom exception holding `amount – balance`. Read balance and withdrawal. Catch it and print ‘Overdraft by [deficit]’. If successful, print ‘Remaining: [balance]’.

Input Format

Two space-separated integers.

Output Format

Print remaining balance or overdraft amount.

Constraints

None

Sample Input

100 150

Sample Output

Overdraft by 50

Explanation

A complete, robust workflow combining custom exception inheritance, state payloads (deficit), method overriding, and OOP protection logic.

Starter Code

#include <iostream>
#include <exception>

class BankOverdraftException : public std::exception {
    // Store deficit and override what()
};

class BankAccount {
    // Implement balance and withdraw()
};

int main() {
    // Read input and execute workflow
    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