Ignore my comment. I wasn't thinking straight.
The issue is that this code is defined in a header file.
This means that for every .cpp file that includes this, the function code is defined (under the same name).
The
#pragma once
only stops this file getting included more than once by any 1 cpp file, it doesn't stop it getting included my multiple files.
Either give the function prototype in the header, and define the code in just 1 cpp file, or add the
inline
keyword to the start of the functions
inline void Con( int (Component::*MFP)(bool) )
{ std::cout << "Con Passed Non-Const MFP\n"; };
inline void Con( int (Component::*MFP)(bool) const )
{ std::cout << "Con Passed Const MFP\n"; };
The inline keyword makes the compiler essentially copy and paste the function code everywhere the function is called, without defining an actual function. This is a bit of a hack up, but works.