How override works


I'm learning about the virtual table in association with virtual methods. I got most of the logic and understanding down (I believe) for when you use 'override' and no 'override' or no 'new' modifier. What I'm trying to figure out now is what happens when you do use modifier 'new' on a derived class method inherited from the base class?

My understanding for the override mechanism with the following code:

class Base
{
public virtual void Method( )
{
}
}

class Derived : Base
{
public override void Method( )
{
}
}


...is that the vtable will replace the Base.Method() address by making the slot in the array of pointers (where Base.Method resides) point to the new override method declared in the Derived class. Correct?

My understanding for when you do not 'override' or 'new' the base method in the derived class is this: The vtable will not change where the Base.Method address resides in the the slot in the array of pointers, of the vtable, so, we'll be using the same base method. Yes?

Now to my main question: what happens when you do use the 'new' modifier on the derived method? How will the vtable look?


vtable, is a mechanism used in a programming language to support dynamic dispatch (or run-time method binding).
Suppose a program contains several classes in an inheritance hierarchy: a superclass, Cat, and two subclasses, HouseCat and Lion. Class Cat defines a virtual function named speak, so its subclasses may provide an appropriate implementation (i.e., either meow or roar).
When the program calls the speak method on a Cat pointer (which can point to a Cat class, or any subclass of Cat), the run-time environment must be able to determine which implementation to call, depending on the actual type of object that is pointed to.