Ver Mensaje Individual
  #7  
Antiguo 28-01-2006
Avatar de Lepe
[Lepe] Lepe is offline
Miembro Premium
 
Registrado: may 2003
Posts: 7.424
Reputación: 29
Lepe Va por buen camino
Yo me quedaría con el uso de punteros, como dice OSKR
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  Tseleccion = function (a,b:Integer):Integer;

  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function An(a,b:integer):integer ;
begin
  Result := a;
end;

function the(a,b:integer):integer ;
begin
  Result := b;
end;


procedure TForm1.Button1Click(Sender: TObject);
  var sel:Tseleccion;
begin
   sel := the;
// aqui podemos elegir tanto la funcion "the" como la funcion "An" ya que 
// ambas tienen el mismo tipo de declaración.

// incluso podemos comparar para saber que funcion tienen:
if @sel = @the then
   ShowMessage('estamos usando la funcion the ');  

// ahora la ejecutamos:
   ShowMessage(IntToStr(sel(3,5)));
end;

end.

saludos
__________________
Si usted entendió mi comentario, contácteme y gustosamente,
se lo volveré a explicar hasta que no lo entienda, Gracias.
Responder Con Cita