C/C++ Function Pointers

The cluster focuses on discussions about function pointers in C and C++, including their syntax, utility, limitations, alternatives like templates and vtables, and comparisons to other languages or mechanisms.

➡️ Stable 0.8x Programming Languages
2,517
Comments
20
Years Active
5
Top Authors
#1654
Topic ID

Activity Over Time

2007
3
2008
3
2009
16
2010
72
2011
66
2012
94
2013
107
2014
117
2015
89
2016
170
2017
169
2018
153
2019
171
2020
190
2021
179
2022
179
2023
189
2024
253
2025
285
2026
12

Keywords

FunctionObject OP C3 AFAIU Stack.push EAX BUT C2 function pointers pointer struct foo void functions int member syntax

Sample Comments

fasterthanlime Feb 29, 2020 View on HN

How do you feel about C's function pointer syntax?

gpderetta Dec 15, 2025 View on HN

Same in C++. You can't do much with the function type itself as there are no objects with that type, but you can create references and pointers to it.

ccosmin Feb 16, 2025 View on HN

No function pointers? That severely restricts the utility of the language…

liuliu Aug 19, 2010 View on HN

I think that he is talking about the cases where you can use template to avoid function pointer in C.

khitchdee Sep 3, 2017 View on HN

Please check your facts. C++ member functions are not as simple as function pointers inside structs.

toast0 Jul 8, 2015 View on HN

Most 'non-fuctional' languages have function pointers too, it just might be less idiomatic.

codr7 Mar 13, 2025 View on HN

At least in C it's only plain old function pointers.You don't have to think about exceptions, overloaded operators, copy constructors, move semantics etc.

the_gorilla Oct 8, 2024 View on HN

Why are some functions addressable in C++ and others not? Seems like a pointless design oversight.

ordu Oct 10, 2023 View on HN

Don't use pointers to functions, or if you must then hide them behind typedefs.

blt Jun 24, 2014 View on HN

Aren't std::functions effectively using something like vtables though?