void close() {
//game.close();
}
int main(int argc, char** argv) {
game.display();
game.attachEvent(Event::EventType::Closed, close());
while (game.isOpen()) {
game.render();
}
return 0;
}
error: cannot initialize a parameter of type 'void (*)()' with an rvalue of type 'void' game.attachEvent(Event::EventType::Closed, close());
note: passing argument to parameter here
void attachEvent(sf::Event::EventType, void (*)());
Why is it displaying this error? I am trying to attach an event which I can call with function();
. As a parameter, it is declared as void (*function)()
.
Thanks.
game.attachEvent(Event::EventType::Closed, close);
&
for readability -&close
but that is optional in this case