Didnt want to put a really long title, continuing – without modifying the base class and without copying one by one.
Lets say the base is CClient, but I dont want to add or remove anything:
class CClient
{
public:
void (*Connect)();
void (*Disconnect)();
bool m_bIsConnected;
};
And say this is derived CClientHook.
class CClientHook : public CClient
{
public:
bool Setup(bool hook);
bool m_bIsHooked;
};
How can I copy values from CClient object to CClientHook object safely? Sorry for weird wording.
EDIT: To clarify, there are two objects and no, Connect and Disconnect arent supposed to be methods.
CClient g_Client;
CClientHook g_ClientHook;
>Solution :
Given
CClient a;
CClientHook b;
There are at least two options:
static_cast<CClient &>(b) = a;b.CClient::operator=(a);