On Fri, 14 May 2010 16:45:50 +0200 Graeme Geldenhuys <graemeg.li...@gmail.com> wrote:
>[...] > > I got similar issues with TStrings and TStringList. TStringList is a > descendant of TStrings, but I can't pass a TStringList type as a parameter > to a method declared with TStrings. > > > Maybe I don't understand the var parameter correctly (but haven't tested to > see what happens if I remove var from parameter list). If I have a class > instance, when should I pass it to a method or function/procedure as var > and when don't I need to use var parameters? "var" means, you can do this: type TQStrings = class(TStrings) end; procedure A(var s: TStrings); begin s:=TQStrings.Create; end; Then your TStringList will no longer be a TStringList. That's why 'var' must match exactly. Same for out. Const and no modifier allows to pass descendants. Mattias _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel