Re: [fpc-pascal] Extend multiple classes with same code

2012-05-19 Thread Zaher Dirkey
On Sat, May 19, 2012 at 7:54 PM, Jorge Aldo G. de F. Junior < jagf...@gmail.com> wrote: > but i cant imagine someone > creating a helper class for TObject). > It is in the example above but in real it base class of mine, TmncCustomField in fact But it fail for me, because there is overridden func

Re: [fpc-pascal] Extend multiple classes with same code

2012-05-19 Thread Jorge Aldo G. de F. Junior
So basically they are in the same branch (Well you could argue that every object inherits from TObject, but i cant imagine someone creating a helper class for TObject). > Please not that the extended classes (in this case T_B1 and T_B2) need to > inherited from T_A, otherwise the compiler will com

Re: [fpc-pascal] Extend multiple classes with same code

2012-05-19 Thread Sven Barth
On 19.05.2012 16:28, Zaher Dirkey wrote: On Sat, May 19, 2012 at 2:10 AM, Jorge Aldo G. de F. Junior mailto:jagf...@gmail.com>> wrote: You simply cant do it. Not even multiple inheritance would help you in this case. You will have to extend each class by hand. Multiple inherita

Re: [fpc-pascal] Extend multiple classes with same code

2012-05-19 Thread Zaher Dirkey
On Sat, May 19, 2012 at 2:10 AM, Jorge Aldo G. de F. Junior < jagf...@gmail.com> wrote: > You simply cant do it. Not even multiple inheritance would help you in > this case. > > You will have to extend each class by hand. > > Multiple inheritance would allow you to join back branches in the > clas

Re: [fpc-pascal] Extend multiple classes with same code

2012-05-18 Thread Jorge Aldo G. de F. Junior
You simply cant do it. Not even multiple inheritance would help you in this case. You will have to extend each class by hand. Multiple inheritance would allow you to join back branches in the class hierarchy, but in this case you want to add the same functionality to multiple branches, but keep t

Re: [fpc-pascal] Extend multiple classes with same code

2012-05-18 Thread Zaher Dirkey
On Fri, May 18, 2012 at 11:27 PM, Bernd wrote: > > _B3 = class(T_A); > How about this: > > T_A = class(TObject); > > T_AX = class(T_A);// <-- this class implements your extensions > > T_B1 = class(T_AX); // TB_1 and > T_B2 = class(T_AX); // TB_2 inherit it > T_B3 = class(T_A); > > > I can't

Re: [fpc-pascal] Extend multiple classes with same code

2012-05-18 Thread Bernd
2012/5/18 Zaher Dirkey : > Hi, > > 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); How about this: T_A = class(TObject); T_AX = class(T_A);// <-- this class implements your extensions T_B1 = class(T_AX);

Re: [fpc-pascal] Extend multiple classes with same code

2012-05-18 Thread Sven Barth
On 18.05.2012 20:38, Zaher Dirkey wrote: Hi, 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

Re: [fpc-pascal] Extend multiple classes with same code

2012-05-18 Thread Zaher Dirkey
On Fri, May 18, 2012 at 9:18 PM, Michael Van Canneyt wrote: > > Maybe you can try interfaces and interface delegation. > > I don't think so, class T_A is not my code or it is very strict to modify it, also i am talk about multiple implementation not interfacing objects (or you can provide me and

Re: [fpc-pascal] Extend multiple classes with same code

2012-05-18 Thread Michael Van Canneyt
On Fri, 18 May 2012, Zaher Dirkey wrote: Hi, 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

[fpc-pascal] Extend multiple classes with same code

2012-05-18 Thread Zaher Dirkey
Hi, 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