zoukankan      html  css  js  c++  java
  • 1 virtual

    1 differents:

    'virtual' just in C#  

    In Java It does't have the keyword

    2 Usages in C#

             used in base class,two situations as following :

            • If you define one function by 'virtual' in base class,and you don't override this function in derived classes. when it invoked, the function in base class will be call back.

            • If you define one function by 'virtual' in base class,and you do override this function in derived classes. when it invoked, the function in derived class will be call back.

    What is virtual function?

    This means that it does not  really exist in the Memory until the object will have  been instantiated.

    3 Usages in Java

              firstly, there is no keyword of 'virtual'

              In Polymorphism, when the object reference of superclass appoint to the object of superclass, if you want to invoke the functions in subclasses,you must add the '@override' above the fucntions you overrided in the subclasses.

              For you reference, pls see the article named 'Factory Method'.

    Aimer,c'est partager
  • 相关阅读:
    973. K Closest Points to Origin
    919. Complete Binary Tree Inserter
    993. Cousins in Binary Tree
    20. Valid Parentheses
    141. Linked List Cycle
    912. Sort an Array
    各种排序方法总结
    509. Fibonacci Number
    374. Guess Number Higher or Lower
    238. Product of Array Except Self java solutions
  • 原文地址:https://www.cnblogs.com/pickKnow/p/8446906.html
Copyright © 2011-2022 走看看