Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Pointers to members

This topic is 5293 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
      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;
        cout <<  pf << ' '<< pff << ' ' << p_i << ' ' << p_k;
[edited by - dzl on March 25, 2004 7:32:07 AM]

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
AFAIK, you should make class members static for those functions you want to pass the pointer.

Your getting around this by using the namespace (class) qualifier. (myclass:

Look up functors instead.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!