Over the past couple of months I have used C # a lot and am used to events and delegates. It is very easy to use in your classes, just use events to receive messages from the component ... Now I'm trying to do something like this in C ++ and I don’t know how to do it.
How is composition performed in C ++? The only way that comes to my mind is inheritance ... do you exit the class and redefine its functions in order to receive data from it? Is there any other way (better)?
More details
I want to write a reusable component like this ...
public delegate void OnDataReceivedHanlder(byte[] data);
public class TcpConnection
{
public void Connect(string iP, ushort port);
public void Send(byte[] data);
public event OnDataReceivedHandler OnDataReceived;
}
in C ++ ...
rusbi source
share