How to obtain the address of the overload function-reply to the "flq_00000" question

Source: Internet
Author: User
Problem Source: http://www.cnblogs.com/del/archive/2008/07/30/1039045.html#1272783
In the compiler's opinion, the overloaded functions are basically different functions, of course there will be different function addresses; the addresses we get in the conventional method are only the first overloaded addresses.
Code File:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs; Type tform1 = Class (tform) Procedure formcreate (Sender: tobject); end; vaR form1: tform1; implementation {$ R *. DFM} {example two overloaded functions} function myfun (S: string): string; overload; begin result: = s; end; function myfun (I: integer): string; overload; begin result: = inttostr (I); end; {obtain the address of the overload function respectively} procedure tform1.formcreate (Sender: tobject); type {two method types need to be defined first, the parameters correspond to the above overload functions} TF1 = function (s: string): string; TF2 = function (I: integer): string; var F1: TF1; {reload 1} F2: TF2; {reload 2} S1, S2: string; begin F1: = myfun; {Let F1 point to reload 1} F2: = myfun; {Let F2 point to reload 2} {test function} S1: = F1 ('abc'); S2: = F2 (123); showmessagefmt ('% s, % s ', [S1, S2]); {ABC, 123} {the first two values are the addresses of the two overloaded functions. The third value is obtained based on the function name, it is the same as the address of the first overload} showmessagefmt ('% P, % P, % P', [@ F1, @ F2, @ myfun]); {another method} showmessagefmt ('% P, % P, % P', [ADDR (F1), ADDR (F2), ADDR (myfun)]); {if it is a method in the published area, you can also use methodaddress to obtain the address} end; end.
 
  
 

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.