I barely know c++.Not an expert.
I am looking through an already existing code.
I could not able to understand this following code.
typedef enum
{
eEvent_MsgOk,
eEvent_InvalidMsgId,
eEvent_Failure,
} eEventType;
class Rs232Event
{
public:
Rs232Msg* m_pMsg;
eEventType m_eEvent;
}
Rs232Event::Rs232Event(eEventType eEvent,Rs232Msg* pMsg)
: m_pMsg(pMsg), m_eEvent(eEvent)
{
// not implemented on purpose
}
Here using the initialisation list they are intialising the values.
But the Rs232Msg class doesnt have a single parameterised constructor.
But its having a constructor which accepts 4 parameters.
I could not identify how its getting invoked.But the code runs without any error.
m_pMsgisn’t anRs232Msgclass. Rather, its a pointer to anRs232Msgclass. All that is being copied is a pointer to an already-existing instance of that class, so the constructor isn’t being invoked here.