What is the expected behavior of the following code?
What is the expected behavior of the following code?
A
because of the typos: A. it raises an exception
which typos?
Using correct mangling, o._Class__foo(), gives an output of 2. So answer is A.
Mangling error
if we magle correctly, we would get the output 2, which is not in the answer list. The first call to o._Class__foo() increments Var by 1 and returns the updated value, which is 1. The second call to o._Class__foo() again increments Var by 1 (now it's 2) and returns the updated value, which is 2.