[fpc-devel] Overloading methods of a parent class

Sven Barth pascaldragon at googlemail.com
Wed Feb 9 10:43:40 CET 2011


Hello together!

I'm currently trying to implement the overloading of methods in class 
helpers, but I now have the problem that I don't know where I should 
touch the compiler.
So my question is the following: How does overloading methods that are 
defined in different (but related) classes work in the compiler?

Following example:

TClass1 = class
   procedure Test(aValue: Integer); overload;
end;

TClass2 = class(TClass1)
   procedure Test(aValue: String); overload;
end;

var
   c: TClass2;
begin
   c.Test(42);
end.

Where does the compiler decide which method to call? And how does the 
compiler know which methods are available?
The latter question can be understand as: Does the compiler search the 
correct symtable (in this case that for TClass1) when it parses the 
factor "c.Test" or does it resolve that already when parsing the 
definition of TClass2?

I'll continue searching the correct spot nevertheless.

Regards,
Sven



More information about the fpc-devel mailing list