看别人写的代码,发现有的函数调用前面写着inherited,
不大明白是什么意思。
哪位大侠能解释给小弟听听,是不是函数和过程的调用前面都可以使用inherited?再什么情况下用?
如果再举几个例子就最好不过了,xixi...^_^

解决方案 »

  1.   

    inherited是继承,找些delphi书看看吧:)
      

  2.   

    inherited 是一种继承调用!是多态的产物!
    The reserved word inherited plays a special role in implementing polymorphic behavior. It can occur in method definitions, with or without an identifier after it.
    If inherited is followed by the name of a member, it represents a normal method call or reference to a property or field梕xcept that the search for the referenced member begins with the immediate ancestor of the enclosing method抯 class. For example, wheninherited Create(...);occurs in the definition of a method, it calls the inherited Create.
    When inherited has no identifier after it, it refers to the inherited method with the same name as the enclosing method. In this case, inherited takes no explicit parameters, but passes to the inherited method the same parameters with which the enclosing method was called. For example,inherited;occurs frequently in the implementation of constructors. It calls the inherited constructor with the same parameters that were passed to the descendant.
      

  3.   

    hehe,手边暂时没有Delphi的书。
    Delphi的帮助倒是有的,不过看不大明白。
      

  4.   

    比如你新建一个Form1,这个Form1是从另一个已存在的Form继承来的。
    这时,当你对Form1写事件代码时,默认下就会有这个inherited;
    它的意思是在执得你写的代码之前,先执行父类的对应事件中的代码。
    当然,也可以不执行父类的对应事件中的代码,就屏蔽它,这要看实际需要。