[fpc-pascal] multiple inheritence
David Emerson
dle3ab at angelbase.com
Tue Oct 6 02:26:48 CEST 2009
On Sat 3 Oct 2009, dmitry boyarintsev wrote:
> t_double_list = class (t_list_frame)
> private
> flist1 : t_list_frame;
> flist2 : t_list_frame;
> function internal_add (const class_in : class_type) : boolean;
> end;
The idea behind my concept of t_double_list is that it is essentially
one list which is both sorted and sequential at the same time.
One of the great things about OOP is that it helps reduce coding
redundancy. That was one of the primary objectives in my design: code
the stuff for unsorted lists once, code the stuff for sorted lists
once, and code the common ancestor stuff once. I don't want to have to
maintain three nearly-identical versions of find_via_binary_search.
The construct you've created here and named "t_double_list" is not a
list at all; rather, it is a container which holds two lists which must
be maintained independently of one another. Instead of simply inheriting
the methods I need, I must completely rewrite them as methods of the
container class. So this really isn't what I'm looking for.
Thanks for replying, though!
For now I've just inherited from t_unsorted_list, redundantly adding the
sorted_list stuff. Not at all the elegant solution I'm looking for, but
it seems to be the best that can be done.
Cheers,
David
More information about the fpc-pascal
mailing list