Im Artikel <ab8f5bd6.0211251609.79aa9...@posting.google.com>,
juergenschlin...@gmx.de (Juergen Schlinker) schreibt:
Quote
>"Getobject" should be something to reference to the object the
>tfeature-class is created in, being example1 or example2.
Then you must store that information inside the TFeature object (class). The
type of that information must be choosen in an appropriate way, so that all
required information can be retrieved from that data (object/interface) type.
You can use the TObject or TInterfacedObject type for that back-reference, and
test with:
if MyContainer is TExample1 then
TExample1(MyContainer).data := 1
else if MyContainer is TExample2 then
...
It may be simpler to define an IContainer interface, which exposes the data
property or whatever is needed, and construct:
TExample1 = class(TInterfacedObject, IContainer, I1)
...
TFeature = class
MyContainer: IContainer;
...
Even easier, but perhaps not illustrative for the use of interfaces, you can
construct a base class:
TFeaturedExample = class(TInterfacedObject)
procedure showme; virtual; abstract;
...
and override the showme procedure in the derived classes:
TExample1 = class(TFeaturedExample, I1)
procedure showme; override;
...
Then you also can make the showme procedure part of I1 and I2, if that helps.
What you tried to implement is a showyou procedure, which is difficult to
implement from outside a class. What should showyou do, when it is given an
object of an unknown and consequently unhandled type?
[It should call showme of the given interface or object ;-]
DoDi