阅读背景:

这将如何运作? (接口和非虚函数)

来源:互联网 
interface I { int J(); }

class A : I
{
   public  int J(){return 0; }  // note NOT virtual (and I can't change this)
}

class B : A, I
{
   new public int J(){return 1; }
}


B b = new B();
A a = b;
I ib = b, ia = a;

b.J(); // should give 1
a.J(); // should give 0 (IMHO)

ia.J(); // ???
ib.J(); // ???
interface I { int J(); }

class A : I
{
   publ



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: