Quote:
1. Why I am not able to access S class method.
You actually can.
Since, by the very inheritance concept,
M
is S
, you may call it.
However,
M::myFunc
hides
S::myFunc
, so you need a workaround, e.g.:
int k = (mm as S).myFunc(1,2);
Quote:
2. And why am I able to create the method with the same name in class M
Because the compiler (reluctantly :-) ) allows that. However, if shadowing the method is really your intention, then you'd better inform (as already suggested) the compiler itself using
new
.