Reimar Grabowski schrieb:
On Tue, 17 Apr 2012 19:46:08 +0200 Sven Barth
<[email protected]> wrote:
Well... class helpers are at least an officially supported hackish
approach unlike other forms of making a protected member visible.
Deriving my own class is certainly more work (as in more to type) but
it is officially supported and I fail to see the hackish part.
That's okay when you *can* create instances of your classes. But often a
user has to deal with an object of an *predefined* type, so that
deriving a class; which is never instantiated; is of no use.
And that's where the hack enters the scene: The mere declaration of a
derived class, or a typecast of a given object into a derived class,
allows the user to access members which are not accessible in the actual
(dynamic) type of that object.
It should be mentioned that class helpers do not solve all problems,
e.g. when a TStrings parameter is passed to a subroutine, in which it's
*assumed* that it actually is of type TStringList. Then a typecast of
that parameter is required, before a class helper for TStringList can be
used with it. Failing to use an *checked* typecast here, what's common
practice <sigh>, may result in any kind of trouble.
DoDi
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus