вообще православные люди делают так:
class Button
{
public:
struct Action
{
virtual void action() = 0;
};
private:
Action *action;
public:
void onAction(Action *act)
{
action = act;
}
void Action()
{
action->action();
}
};
struct ToStdCOutAction : Button::Action
{
virtual void action()
{
std::cout<<"нажали на кнопку"<<std::endl;
}
};
int main()
{
Button *but = new Button();
but->onAction(new ToStdCOutAction());
but->Action();
return 0;
}