delorie.com/archives/browse.cgi | search |
From: | Dave Bird <dave AT xemu DOT demon DOT co DOT uk> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: Pointers to functions. |
Date: | Sun, 7 Mar 1999 18:18:30 +0000 |
Organization: | very little |
Message-ID: | <u79p7SA2Ls42EwHc@xemu.demon.co.uk> |
References: | <7b9jku$o7o$1 AT news6 DOT svr DOT pol DOT co DOT uk> <36D9BD2F DOT A05C8E55 AT cartsys DOT com> |
<CqyGOCASqC42EwDb AT dunvegan1 DOT demon DOT co DOT uk> <7br6n8$897$1 AT news6 DOT svr DOT pol DOT co DOT uk> | |
<7bu8hk$6b6$1 AT camel19 DOT mindspring DOT com> | |
NNTP-Posting-Host: | xemu.demon.co.uk |
X-NNTP-Posting-Host: | xemu.demon.co.uk:158.152.196.209 |
X-Trace: | news.demon.co.uk 920837909 nnrp-10:15236 NO-IDENT xemu.demon.co.uk:158.152.196.209 |
X-Complaints-To: | abuse AT demon DOT net |
MIME-Version: | 1.0 |
X-Newsreader: | Turnpike (32) Version 4.01 <dQumtnY$x4rJ2u5tL5fS$n2vuP> |
Lines: | 26 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
In ar<7bu8hk$6b6$1 AT camel19 DOT mindspring DOT com>, Lark <rlark AT at DOT mbhs> writes > >What is the purpose(point, if you will) of having a pointer to a function? so that a 'C' variable can indicate a 'variable' sort of function i.e. a different actual function to be used in different contexts. For example: You might want to write a clever sort algorithm which can sort many different kinds of data. Let's assume it can cope correctly with the varying lengths of data and find the next record all right. Then you might have a parameter which was int (*compare)(); i.e. what compare points at is a function that returns int being -1 0 +1 for less or equal or greater. Of course it would be a different function depending on whether the objects you were sorting were strings, 128bit integers, polygons, or whatever. -- ^-^-^-@@-^-;-^ http://www.xemu.demon.co.uk/ (..)__u news:alt.smoking.mooses
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |