On Wed, 27 Feb 2013, xrfang wrote:

Hi,
Is it possible to do the following:

=== example ===

program test;
type

  TMyClass = class
  type
    TDataFilter = function 
  public
    Value : Double;
    Filter: TDataFilter;
    procedure ViewData;
  end;
procedure TMyClass.ViewData;
begin
  if Filter = nil then
    WriteLn(Value)
  else
    WriteLn(Filter(Value));
end;

var
  t : TMyClass;
begin
  t := TMyClass.Create;
  t.Value = 2;
  t.Filter := @sqr;   //this does not work
  t.Filter := @ln;    //this does not work either
&nbs p; t.ViewData;
  t.Free;
end.
=========

The problem is, while assign function pointers to Filter, I would like to make 
it accept all numeric functions.  That is, if I
define it to accept Double, it should accept Single and Integers, and if I 
define it to accept Extended, it should accept all
numbers.

Possible?

No.

Michael.
--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to