Confusion about virtual/new/override

后端 未结 5 1456
暗喜
暗喜 2020-12-15 01:06

I am a bit confused about the virtual/new/override thing. Here\'s an example:

class A
{
    public virtual void mVVirt         


        
5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 01:28

    This is how I understand it

    A is the base class
    B inherit A but doesn't override it
    C inherit B but does override it

    Since you are declaring A but initialize C, it will ignore the override because the base class is A and A never get overridden from B.

提交回复
热议问题