Jump to content
  • Advertisement
Sign in to follow this  
DMINATOR

pointer to diferent member functions

This topic is 4769 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

Is it possible , to make a pointer that can point to different member functions ? I know that I can create a pointer to a member function like that :
#include <stdio.h>

int temp = 0;

class Test
{
public:

	void Start()
	{
		temp = 20;
	};
};

//to class
void (Test::*pt2Func3)(void);


int main()
{

	 pt2Func3 = &Test::Start;


	 printf("temp = %d\n",temp);


	 //create the class we wan't to use with
	 Test test;

	 //let's call the function then
	 (test.*pt2Func3)();

	 printf("temp = %d\n",temp);

	return 0;
}

But if for example I have 2 different classes and I wan't to make a pointer that can point to any member function in these classes. Can it be done ? Thanks for any input.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • 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!