Delphi Class of reference

Source: Internet
Author: User
Http://www.cnblogs.com/yangxuming/p/6707459.html

Type
Tcontrolcls = Class of Tcontrol;
function Createcomponent (CONTROLCLS:TCONTROLCLS): Tcontrol;
Begin
Result:=controlcls.create (FORM1);
...
End
function Createcomponent (Controlcls:tcontrol): Tcontrol;
Begin
Result:=controlcls.create (FORM1);
...
End

The former requires passing in a class, and the latter requires passing in an object (an instance of the class)
Type
MYCLASSREF=CALSS of CMyClass//represents myclassref as a pointer to CMyClass or its parent class

A reference to a class is just like a pointer to a class
A class reference is the type of a class, and you can declare a class reference variable to assign it to a class, and you can create an instance of the object from that variable.

Classes and the like
When you are unsure of the class model to invoke, use the class.
It can also be said to be a class pointer ~

At the time of program compilation, you want to call the category method with a category name or a special item. Or a virtual constructor, but you do not know the actual data type of the class or object, this time the category reference is very useful.

Delphi Class of reference

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.