What are Virtual Methods?

前端 未结 14 586
傲寒
傲寒 2020-11-29 03:02

Why would you declare a method as \"virtual\".

What is the benefit in using virtual?

14条回答
  •  旧巷少年郎
    2020-11-29 03:42

    A virtual method is a type of method where the actual method calls depends on the runtime type of the underlying object.

    A non-virtual method is a type of method where the actual method called depends on the reference type of the object at the point of method invocation.

提交回复
热议问题