Error message:
...error C3867: 'temp::addition': function call missing argument list; use '&temp::addition' to create a pointer to member

#include "stdafx.h"
#include <iostream>

using namespace std;

struct temp
{
	int addition(int x, int y)
	{return (x + y);}

	int operation (int x, int y, int (*functocall)(int,int))
	{
		int g;
		g = (*functocall)(x,y);
		return (g);
	}
};


int main ()
{
  int m;
  
  temp momo;

  m = momo.operation(3, 4, momo.addition);  // !!!???
  cout << m;

  cin.get();
  return 0;
}
m = momo.operation(3, 4, momo.addition);

Try to send a reference of that function .

m = momo.operation(3, 4, &momo.addition);

Try to send a reference of that function .

m = momo.operation(3, 4, &momo.addition);

syntax error, dude.

.

nice site. but reading thru all that would rather have me getting over this.

Easy way out. Make member func static :

#include <iostream>

using namespace std;

struct temp
{
	static int addition(int x, int y)
	{return (x + y);}

	int operation (int x, int y, int (*functocall)(int,int))
	{
		int g;
		g = (*functocall)(x,y);
		return (g);
	}
};


int main ()
{
  int m;
  
  temp momo;

  m = momo.operation(3, 4, temp::addition);  
  cout << m;

  cin.get();
  return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.