#include <iostream>
#include <string>
using namespace std;

class Account {
private:
    string owner;
    int balance;
    int limit;

public:
    Account(string owner, int balance, int limit): 
        owner(owner), balance(balance), limit(limit) {}

    void withdraw(int amount) {
        if (amount > balance || amount > limit) {
            cout << "출금 불가" << endl;
        } else {
            balance -= amount;
            cout << amount << "원 출금 완료, 잔액: " << balance << "원" << endl;
        }
    }

    void transfer(Account &target, int amount) {
        if (amount > balance || amount > limit) {
            cout << "이체 불가" << endl;
        } else {
            balance -= amount;
            target.balance += amount;
            cout << amount << "원 이체 완료" << endl;
        }
    }

    int getBalance() const {
        return balance;
    }
};

int main() {
    Account acc1("홍길동", 10000, 5000);
    Account acc2("이순신", 2000, 5000);

    acc1.withdraw(6000);
    acc1.transfer(acc2, 3000);

    cout << "홍길동 잔액: " << acc1.getBalance() << "원" << endl;
    cout << "이순신 잔액: " << acc2.getBalance() << "원" << endl;

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: