Can you override a C++ message callback

asked 2016-04-13 03:35:44 -0600

Felix Duvallet gravatar image

I have a Parent() class that subscribes to a message /foo with a method messageCallback.

Can a derived class Child : public Parent override the messageCallback method to get notified each time a new /foo message arrives?

The alternative I've come up with is to have both Parent and Child subscribe to the /foo message and do separate things in their separate callbacks.

edit retag flag offensive close merge delete

Comments

I haven't verified this, but if you'd use boost::bind(..), it should allow you to bind a virtual method (see here), which you could then override in your subclass.

gvdhoorn gravatar imagegvdhoorn ( 2016-04-13 03:47:59 -0600 )edit