Skip to main content
gamedev.net
🔒 Locked

Pointers to members

Started by dzl Mar 25, 2004 at 6:28 AM 1 replies 250+ views
Original Post
dzl
dzl
Why are the first adresses the same? But works well... How does the compiler implement it? Thanks to all!
#include <iostream>
using namespace std;
class myclass
{
public:
      void f(){cout<<" f() "<<endl;};
      void ff(){cout<<" ff() "<<endl;};
      int _i;
      static int _k;
};

int myclass::_k = 555;
 
int main()
{
        myclass mc;
        void (myclass::*pf)() = &myclass::f;
        void (myclass::*pff)() = &myclass::ff;
        int  myclass::*p_i = &myclass::_i;
        int  *p_k = &myclass::_k;
        (mc.*pf)();
        (mc.*pff)();
        cout <<  pf << ' '<< pff << ' ' << p_i << ' ' << p_k;
}
[edited by - dzl on March 25, 2004 7:32:07 AM]
More...
Qw3r7yU10p!
Qw3r7yU10p!
quote:
Original post by Anonymous Poster
AFAIK


Who are you? And why should I trust you?

quote:
you should make class members static for those functions you want to pass the pointer.


sigh... function-pointer.org

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.