Hello there. I have here a constructor of class CDriveControl and class CSPTIDriver..
class CSPTIDriver;
class CDriveControl{
public:
CDriveControl();
CDriveControl(const char* pPort);
......
......
protected:
char* m_pPort;
CSPTIDriver* m_pSPTIDriver;
bool m_bInitFlag;
bool m_onlycomp;
}
It was defined outside the class.
CDriveControl::CDriveControl(void)
:m_pPort(NULL) //Object drive
,m_pSPTIDriver(NULL) //SPTI object
,m_bInitFlag(false) //Formatted flag
,m_onlycomp(false)
{
}
CDriveControl::CDriveControl(const char* pPort)
:m_pPort(NULL) //Object drive
,m_pSPTIDriver(NULL) //SPTI object
,m_bInitFlag(false) //Formatted flag
,m_onlycomp(false)
{
if(pPort == NULL){
Trace(false, "CDriveControl();pPort==NULL\n");
return;
}
//Port name is kept
m_pPort = new char[strlen(pPort)+1];
strcpy(m_pPort, pPort);
// ::InitializeCriticalSection(&m_cCrtSection);
}
My question is, what is the reason that these protected variables where placed here?
CDriveControl::CDriveControl(void)
:m_pPort(NULL) //<---here
,m_pSPTIDriver(NULL) //<---also here
,m_bInitFlag(false) //<---guess what?
,m_onlycomp(false) //<---you got it right again!
{ //<---what's up with this?
} //<---and this one too?
I searched some function tutorials but I was not able to find any explanation with this one. I'm currently studying classes and I was able to find this example code of constructor. Could anyone explain to me what is the use of doing that? I'm a having a hard time realizing what in the world is it's purpose. Thank you very much...