> fpc 1.1 gives the following error message: > overloadedcontructor.pas(36,32) Error: Can't determine which overloaded > function to call overloadedcontructor.pas(19,19) Hint: Found > declaration: constructor TBase.Create(TComponent) > overloadedcontructor.pas(26,23) Hint: Found declaration: constructor > TSubClass.Create(TStrings) overloadedcontructor.pas(39) Fatal: There > were 1 errors compiling module, stopping
In a way that makes a lot of sense... however it's a symptom of the way FPC does overloading in objfpc mode. I've no idea why it's broken between 1.0 and 1.1, I can only think it's related to a missing patch? Explanation: To the compiler, your declaration of the constructor is 'Create( Areference to object )' in both cases. The Object you pass is typed, so the compiler will pick the overloaded constructor that fits the type you are passing. It looks as if the logic concerning the presedence that a constructor has over other overloaded constructors has changed. One would assume that it used to be 'child class overrides the parent class', hence 1.0 works. It seems that 1.1 takes all methods as equal, and passing 'nil' causes a paradox because nil is a possible value for both overloaded constructors. In Delphi syntax, we have to explicitly define overloaded methods, procedure x; overload; procedure x(s: string); overload; and this situation becomes clearer. I also believe the overloading rules are tighter in Delphi and you wouldn't be able to do what you are doing anyway. I suggest that your code needs to mark your constuctors as virtual, and that your second class could override the first's constructor and call inherited to pass the correct param. I don't see an advantage to passing completely different classes as params to overloaded constructors otherwise. Also remember that you can have constructors with different names (Create, CreateStringList, etc) and so you could get around the issue that way. Hope that elps, Matt _______________________________________________ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal