- , , ?
B class C : B. : ( .)
class D { class E {} }
class J {
class E {}
class K : D {
E e;
}
}
J.E D.E; ? # - , , . K E , , , E .
But we see that the puzzle has the same structure; it's just getting confused by generics. We can consider the generic one as a template, and simply write out the A-of-string and A-of-int constructions as classes:
class A_of_int
{
class B : A_of_int
{
void M() { Write("int"); }
class C : B { }
}
}
class A_of_string
{
class B : A_of_int
{
void M() { Write("string"); }
class C : B {}
}
}
And now it should be clear why he A_of_string.B.M()writes string, but he A_of_string.B.C.M()writes int.
source
share