[fpc-pascal] Extend multiple classes with same code

Zaher Dirkey parmaja at gmail.com
Fri May 18 20:38:50 CEST 2012


I have 2 objects inherited from the base one

T_A = class(TObject);

T_B1 = class(T_A);
T_B2 = class(T_A);
T_B3 = class(T_A);

Now if I want to extend T_B1 it is easy to inherit it to T_C1 = class
(T_B1) and add many functions to it, but.

I want the same extend T_B2  not T_B3,

1 - The first idea is adding this functions to T_A, but it is not my class
to modify it, or it is protected from my modify.
2 - Copy and paste this functions to T_B2, but in that case I need every
time to fix functions in B1 I must do it in B2, that make it so hard, and
not good programming quality.

Is there any new idea to do that, what about Helper, generics, i read about
it i felt it is not fit to my problem (or i am wrong).

Thanks in advance

Zaher Dirkey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20120518/69913e80/attachment.html>

More information about the fpc-pascal mailing list