Question OOP-ENC-0037
EasyWhat is the output of this code?
#include <iostream>
using namespace std;
class Account {
int bal = 100;
public:
void deposit(int x) {
if (x > 0) bal += x;
}
int get() { return bal; }
};
int main() {
Account a;
a.deposit(50);
a.deposit(-30);
cout << a.get();
}
- A.
100
- B.
120
- C.
Sign up free to see the answer and a step-by-step explanation.