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
  • 相关阅读:
    设计模式浅谈
    链表的遍历(1)
    链表的删除(3)
    链表结构的反转(5)
    二叉树数组表示法
    循环链表的插入和删除
    链表的链接(2)
    双向链表内结点的删除(4)
    hdu1042
    数组和链表的区别
  • 原文地址:https://www.cnblogs.com/pickKnow/p/8446906.html
Copyright © 2011-2022 走看看