Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 16874

Pointer to member function with default variable value

$
0
0

I'm trying to call a member function that has a default variable value, ie: void func(size_t x = 1234) { }

Is there any way to omit the function parameter when called via a pointer to member function?

#include <iostream>
using namespace std;


class c
{
public:
	int f(size_t x = 1234)
	{
		cout << x << endl;
		return 1;
	}

	bool b;
};

int main(void)
{
	typedef  int (c::* c_member_function)(size_t x);

	c_member_function ptr = &c::f;

	c c_instance;

	(c_instance.*ptr)(1);

	return 0;
}

 

 


Viewing all articles
Browse latest Browse all 16874

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>