Delphi Override, overload, reintroduce the difference -0613.txt

Source: Internet
Author: User

http://blog.csdn.net/honglixx/article/details/3624934 1, what is the Chinese term for the override overload reintroduce?    Override: Overwrite; Overload: Reload; Reintroduce: Redefine 2, override or overload a dynamic or virtual method in a parent class in a subclass to change the corresponding method in the parent class?    Not 3, self is what is going on, how to use? Self because this object itself, for example, in the OnCreate event of TForm1, refers to the object after the TForm1 instantiation, if there is a TButton called Button1 on TForm1,     So Onbutton1click write Self is also TForm1 instantiation of the object, 4, reintroduce and override overload what is the difference, how to use? To declare a method that differs from the parameters of an ancestor class in a descendant class, use the reintroduce, but when you need to redefine the total virtual or dynamic method of an ancestor class, use the override If the methods in the ancestor class are not virtual or dynamic (there is a virtual one, there is a dynamic; that is, dynamically); So there's no way to override it. As for overload, it is generally applicable to a function that defines a set of different parameters. These functions may also not be of the Objects (Chinese how to say?).  )。     Reintroduce is introduced to mask a virtual method of the parent class, and a new method is generated in the subclass; Overload is designed to handle different parameters for methods with the same name; you don't use reintroduce to override methods that mask the parent class, but you create a warning.      Use this keyword to indicate that you want to block this so that no warning is generated! If the class does not inherit from another class (which is actually inherited from TObject), constructor Create;   Virtual virtual function, which means that override;destructor destory:virtual can be quilt class, if inheriting from other classes, such as: Tformconstructor Create (aowner:tcomponent); Override;destructor Destory:override; If a subclass wants to overload a function again, it must be added ReintroDuce and Overloadconstructor Create (aowner:tcomponent); overload; Override The overload must be in front of the override. Constructor Create (aowner:tcomponent; Aparent:twincontrol); Reintroduce; Overload; example unit Unit1;interfaceuses Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms, dialogs;t Ype Ta = Class (TObject) public constructor Create;    Virtual destructor Destory;    Virtual Procedure AAA;  Virtual  End TB = Class (TA) public constructor Create; overload;    Override Constructor Create (a:string); Reintroduce;    overload; destructor Destory;    Override Procedure AAA; overload;    Override Procedure aaa (a:string); Reintroduce;  overload;  End    TForm1 = Class (Tform) procedure formcreate (sender:tobject);  Procedure Formdestroy (Sender:tobject);  Private {private declarations} C:TB; Public {public declarations} end;

  

Delphi Override, overload, reintroduce the difference -0613.txt

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.