Signal handlers versus virtual functions and inheritance (event handling)

I have a base class Window that needs to have events like MouseDown, MouseUp, WindowResized, etc. I have two possible routes: signal handlers (like Boost.Signal) or virtual functions, when the user of the class creates the class it gets out of the window and overrides the OnMouseUp, OnMouseDown and OnWindowResized functions. What are the advantages and disadvantages of each, or is it a matter of style?

I am writing this in C ++, but I think the concept is more important.

Thanks in advance, ell.

+3


source to share


1 answer


This is research related to how different approaches work (plain c, virtual, boost :: signal, etc.). Study

According to this, there are serious problems with boost.signal. To be frank with you, I haven't used this library very much, although I thought it was a very interesting question since I was playing around with the same idea. Anyway, I would go with a virtual implementation.



Respectfully.:)

+1


source







All Articles