I'm using boost::function
to enable the passing of a function to a Button
constructor so it holds that function. Calling it whenever it is activated.
typedef boost::function< void() > Action;
In my TitleState I've constructed a Button like this.
m_play(
ButtonAction, // This is where I pass a function to Button's Action argument
sf::Vector2f( 500, 400 ),
sf::IntRect( 500, 400, 700, 500 )
)
where ButtonAction is a static void
function privately held in TitleState's header, defined in the implementation file as simply outputting to the console via std::cout (just as a test for whether it is working).
In my code, if the mouse clicks a button in TitleState's HandleEvents
function, the program calls that button's Activate
function which looks like this.
void Button::Activate() const {
m_action(); // m_action is the Action member that holds the ButtonAction I passed earlier
}
The problem is that, when the program tries to link I get this error....
unresolved external symbol "public: void __thiscall Button::Activate(void)" (?Activate@Button@@QAEXXZ) referenced in function "public: virtual void __thiscall TitleState::HandleEvents(void)" (?HandleEvents@TitleState@@UAEXXZ)
I'm not sure what the problem is besides that the linker can't find the definition of the function. Everything is #included
or declared properly. Any assistance is appreciated. Thanks.
P.S. When I used the BoostPro installer, I only installed the single-threaded stuff and none of the multi-threaded stuff. Could this be a reason why it isn't working? I read that linker problems can occur when libraries are linking in different ways. If this could be an issue, I'll add that I'm also using the SFML library.