[fpc-pascal] constructor overloads - only class methods can ..?
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:
TmyClass = class(TObject)
constructor Create; overload;
constructor Create(AParam : TAny); overload;
constructor Create(AParam : TAnother); overload;
Temp : TmyClass;
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
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