[fpc-pascal] constructor overloads - only class methods can ..?
Wolfram Kläger
wolfram.klaeger at web.de
Sun Mar 16 00:42:59 CET 2008
>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?
More information about the fpc-pascal
mailing list