Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-03

constructor overloads - only class methods can ..?

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Wolfram Kläger
From time to time I get the error, "only class methods can be referred with class references". While always managed to get a workaround, I am still not able to understand exactly when this happens and why. Example:
type
  TmyClass = class(TObject)
  private
    ..
  public
    constructor Create; overload;
    constructor Create(AParam : TAny); overload;
    constructor Create(AParam : TAnother); overload;
   ...
   procedure DoImportant(...)
  ...
  end;
procedure TmyClass.DoImportant(...);
var
  Temp : TmyClass;
begin
  ...
  Temp := TmyClass.Create(AParam); // error

Calling the same constructor from a separate unit, everything is fine, without error. Can somebody deliver the clue?

Thanks in advance
Wolfram

BTW: Of course, overloading requires unique param type lists. But why is it impossible to overload functions by unique result type?