حساب بنكي مغلّف — تحدي C++
أنشئ صنف Account برصيد خاص. deposit(int) يقبل المبالغ الموجبة فقط، وwithdraw(int) تُرجع true إذا كان الرصيد يكفي (وتخصم)، وbalance() تُرجع الرصيد.
class Account {
public:
Account(int initial) {}
void deposit(int amount) {}
bool withdraw(int amount) { return false; }
int balance() { return 0; }
};حل هذا التحدي يرتبط بفتح دورة «OOP في C++» بحسابك.
ابدأ الحل