Using iheritance or not with buttons

So in my case I'm having a class "Button" witch holds functions which are called when button is pressed. The only thing that button does is that it's calling function when pressed.

A.)Using inheritance for each button that does specific thing. Each inherited class would have it's own function depending what button does. For example "exit_button" would inherit from "button"

B.)Putting all functions in class called "Button" and when button is pressed run a "switch-case" with "button_name" as argument that determines which function to call.

There is not any code to show since this is more logical question. Every button function is to do something on button press ad that is it's only purpose.

Thanks in advance
Last edited on
Option B sounds like you're trying to reinvent the factory design pattern, but for this case this definitely seems the uglier of the two.

I would go for option A.

A pure virtual function in the Button class should be fine.
Topic archived. No new replies allowed.