• Advertisement
Sign in to follow this  

c related

This topic is 4210 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
When you need to pass a function to another function. For example, qsort is written so that it can sort any data type, but you need to pass it a function that knows how to compare two elements.

Or when you want to change the function that gets called in some circumstances, e.g. when a button is pressed. Or if you want to re-implement virtual functions by hand.

Etc.

Share this post


Link to post
Share on other sites
With modern C++ facilities, it's quite unusual to need it. When you do, you'll probably end up asking "how do I do this" and getting an answer about function pointers. Except that you'll actually probably more likely get an answer about functionoids (also called functors), because they're strictly more powerful.

Of course, if you really are stuck with C, you might need them a fair bit more (but again, not for everyday stuff). But then, why would you be stuck with C these days? :(

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement