Visual Studio 2015 “non-standard syntax; use ‘&’ to create a pointer to member”

The fix to your problem is already provided in the answer by drorco. I am going to try to explain the error message.

When you have a non-member function, you can use the function name in an expression without using the function call syntax.

void foo()
{
}

foo; // Evaluates to a function pointer.

However, when you have a member function, using the member function name in an expression without the function call syntax is not valid.

struct Bar
{
   void baz() {}
};

Bar::baz;  // Not valid.

To get a pointer to a member function, you need to use the & operator.

&Bar::baz;   // Valid

That explains the error message from Visual Studio:

"non-standard syntax; use '&' to create a pointer to member"

Leave a Comment