[fpc-pascal]Question on OOP programming...

md md at realmwireless.com
Fri Nov 10 16:55:20 CET 2000

Somehow, use function pointers to let your parent access the specific
child version of the Key( ) function.

Let's say your child overrides your parent, So you child has the
function and your parent does not.  Put 
a pointer to a function inside the parent and assign that pointer after
override, assigning the address of the child function to the pointer in
the parent.  This would allow the parent to test the nil value of the
function pointer
and call it if not nil.

Hope that gives you a way out!

Unfortunately, you would have to provide a pointer for every function
you want to do this with.


Rainer Hantsch wrote:
> Hello, everybody!
> I have a very interesting problem with my programming and I hope there is
> somebody here who knows a solution.
> I wrote a "Database Unit", which offers a basic oDB object for a special
> form of text-based databases. This oDB includes currently everything I
> need for ReadOnly operation. It is kept absolutely neutral, reads the
> whole database file into a list of string on the heap, and allows to
> access the fields by name (so I can add as many fields as I want with the
> same oDB) and moving within this list.
> Now I must add editing, and this includes Sorting. Sorting must be split
> into Sort() which does the basic/physical sorting and KeyGen(), a function
> which creates a sort string out of the currently selected data record.
> To stay neutral at this level, I can only implement Sort() into oDB and
> (possibly) a dummy version of KeyGen(), which must be overloaded later in
> any way inside the client instance.
> It is simple to overload a function from the client view by
> defining it "virtual". From outside access this is ok, but I must
> access this client version of KeyGen() from the parent!!!
> Haw can I do that or something similar? I know that I can fix that with
> workarounds, but this is not my target. I want to keep the internal list
> of records "private" and to offer only methods for accessing it.
> Please, if you know a solution, let me know!
> Thanks in advance,
>   Ing. Rainer Hantsch
>       \\|//           Ing. Rainer HANTSCH  -  Hardware + Software
>       (o o)           Your Partner - Your Supplier - Your Friend!
> --oOOo-(_)-oOOo--------------------------------------------------
> Ing. Rainer HANTSCH  |  e-Mail: office at hantsch.co.at
> Khunngasse 21/20     |  www   : http://www.hantsch.co.at
> A-1030 Vienna        |  Tel.  : ++43 - 1 - 7988538 0
> ---------------------|  Fax   : ++43 - 1 - 7988538 18
> ** AUSTRIA **        |  Mobile: ++43 - 663 - 9194382
> -----------------------------------------------------------------
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

More information about the fpc-pascal mailing list