I’m writing on C#.
I like using event. It’s very natural for my classes to just publish event and don’t care who and how will they process. However as I will need to migrate my code to c++ should I still use event? How easy would be to rewrite such code to c++? Probably it makes sense to use other technics that easier to rewrite to c++?
upd i’ve found similar question C#-like events in C++, Composition
What to use instead of c# event to have code easy to port to c++?
If you are sure what you think about is only related to event, then I think you don’t need to make any change.
Just write a underlying class for event, that reaches your goal.
You might have various ways to do. The first step would be thinkg about CALLBACKs.
Here I provide some code for example, invoking c++ callbacks through P-invoke and wrap into delegates in c#.
Import the callback:
Define the delegate:
Declare the event:
Wrap the event to call:
You’d need to do something reversed/inverted in c++. But first of all, implement a class for event or delegate would get you closer to done what you’ve asked.