[Lazarus] two questions about generics
Xiangrong Fang
xrfang at gmail.com
Fri Feb 22 04:48:51 CET 2013
Hi all,
I have two questions about generics. I am writing a two-dimensional table
class. Say:
type
generic TTable<TValue> = class
... ...
public
constructor Create(ADefaultValue: TValue);
end;
My questions are:
1) if I am not writing a generic class I can define default value for the
constructor, i.e.
constructor Create(ADefaultValue: Double = 0);
for generic classes, how can I define a default value?
2) if I cannot define a default value, I hope to do so while specializing
it. i.e.
type
TNumericTable = specialize TTable<Double>
public
constructor Create(ADefaultValue: Double = 0); override;
end;
That is, can I "inherit" a generic class while specializing it?
Thanks,
Shannon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130222/89eafebe/attachment-0002.html>
More information about the Lazarus
mailing list