Lazarus
Free Pascal => General => Topic started by: simone on April 21, 2017, 01:05:09 pm
Title:
Add members to a specialized generic class
Post by:
simone
on
April 21, 2017, 01:05:09 pm
I have a doubt about generics. When I define a new class, as following
Code: Pascal
[Select]
[+]
[-]
TMyLyst
=
specialize TFPGObjectList<TMyClass>
and I want to add to it some member (i.e. fields/properties/methods), for example:
Code: Pascal
[Select]
[+]
[-]
TMyLyst
=
specialize TFPGObjectList<TMyClass>
procedure
proc1
;
end
;
I have a sintax error. To circumvent the problem I must to derive a subclass and then add to it the new members, as in the following:
Code: Pascal
[Select]
[+]
[-]
TDerivedMyList
=
class
(
TMyLyst
)
procedure
proc1
;
end
;
This is a desidered feauture of syntax or is an issue?
Title:
Re: Add members to a specialized generic class
Post by:
eny
on
April 21, 2017, 03:25:25 pm
Code: Pascal
[Select]
[+]
[-]
TMyLyst
=
class
(
specialize TFPGObjectList<TMyClass>
)
procedure
proc1
;
end
;
Title:
Re: Add members to a specialized generic class
Post by:
simone
on
April 21, 2017, 04:02:59 pm
Simple and compact solution! Thanks!
TinyPortal
© 2005-2018