Author Topic: C++ function pointer in class ?  (Read 11350 times)

0 Members and 1 Guest are viewing this topic.

Offline alanambrose

  • Frequent Contributor
  • **
  • Posts: 377
  • Country: gb
Re: C++ function pointer in class ?
« Reply #25 on: May 12, 2018, 05:13:06 am »
>>> Hi, what should i type to get a function pointer pointing to a function from a class ?

Also check out 'functors'. I've used this technique extensively in the past e.g. for writing general purpose integration or optimisation algorithms that take the function to be integrated / optimised as a function represented as a functor.

A.
“A foolish consistency is the hobgoblin of little minds"
 

Offline Korken

  • Regular Contributor
  • *
  • Posts: 84
  • Country: se
Re: C++ function pointer in class ?
« Reply #26 on: May 13, 2018, 07:45:00 pm »
If you want to call with "pointer to member function", I have made two helpers for that (and a bit more) which can be found here: https://github.com/korken89/esl/tree/master/src/esl/callable
They are made for non-dynamic allocation use, so the esl::function uses a fixed size buffer to store arguments, while esl::function_view does not allow for storing arguments.
 

Offline Daixiwen

  • Frequent Contributor
  • **
  • Posts: 367
  • Country: no
Re: C++ function pointer in class ?
« Reply #27 on: May 14, 2018, 09:03:59 am »
By the way I heard one day about this site which is great to find the syntax of complicated C statements, like function pointers:
https://cdecl.org/ C gibberish to English converter
It doesn't do C++ though.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->