« Playing with openjdk on ppcfirst swig patch! »

Pointers to member functions in C++

2009. Mar. 31.

Permalink 02:26:04 am, by vmiklos, 114 words   English (US)
Categories: hacking

Pointers to member functions in C++

Okay, I learned something new, you can have a special pointer type in C++ which is not really a pointer at all.

So let’s say you have a Foo class with a lot of void foo(int param); methods. Then you can have a “pointer” type ‘int (Foo::*)(int)’ which is in fact a pointer to Foo and it has an offset about what function does it point to.

And given that it contains an address and an offset as well, you can’t cast it to void*, like you can do so with real pointers.

I had to look up the Bjarne book since I didn’t really know about this at all… ;-)

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)
July 2010
Mon Tue Wed Thu Fri Sat Sun
 << <   > >>
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Search

Stats

Összesen 1,455 bejegyzés és 307 megjegyzés.

Most views

  • Sparse checkout example in git 1.7.0 (1,422)
  • winning london (987)
  • pacman -Sy: rsync-like optimization (888)
  • pacman-g2 -Qt bug (876)
  • gmane export (853)
  • More...
powered by b2evolution