1

I stumbled upon weird (for me) construction in B. Stroustrup's book. The code is

int (S::*) pmf() {&S::f};

I am intermediate in C++, but I don't even know, what should I look for in Google and SO. I don't understand above construction, can you help me or point me to a good source?

Seu
  • 45
  • 1
  • 5
  • 2
    Should be `int (S::*pmf)() {&S::f}` and it means "`pmf` is a pointer to member function of `S` that takes no arguments and returns `int`, initialized to the address of the member function `S::f`. – David G Jun 24 '15 at 18:22
  • perhaps this will shed some light: http://stackoverflow.com/questions/4984600/when-do-i-use-a-dot-arrow-or-double-colon-to-refer-to-members-of-a-class-in-c – Snappawapa Jun 24 '15 at 18:23
  • Lookup for [member function pointer](http://stackoverflow.com/search?q=%5Bc%2B%2B%5Dmember+function+pointer+what+is) – πάντα ῥεῖ Jun 24 '15 at 18:24
  • I gave up understanding function pointer declarations (member function declarations are worse), and google it every time, if I really need some. On the other hand, std::function with a signature is nice. –  Jun 24 '15 at 18:27
  • You misspelled it, but here is a [demo](http://ideone.com/0okuhS) of what you may have meant. – Kerrek SB Jun 24 '15 at 18:29
  • So it is misspelled in the book (polish version), I thought it is some kind of tricky and exotic coding ;] Thanks guys for your answers and links. – Seu Jun 24 '15 at 18:40

1 Answers1

0

pmf() is a member function pointer for a member function S::f which return int and accept no parameters.

Steephen
  • 14,645
  • 7
  • 40
  • 47