Reference class from global
-
I have a fragment of code as an example, and I'm trying to figure out what it does and how.
void WINAPI CLeft::Abc(LinkPtr pData) { g_Spec().Xyz(pData); }
I know CLeft::CLeft is a global outside of any class. It receives callbacks from a server. I know Xyz is in a class. I know the pointer pData is being passed. I think both Abc and Xyz are defined in the same file. I'm not sure whatg_Spec().Xyz()
really is. I'm trying to figure out how and where one definesg_Spec().Xyz(pData)
so it can 1)be referenced by Xyz 2)be a class or within a class Anything look familiar? I really don't know if there is enough here to provide sufficient information. I am currently using the following and don't like it. It seems too complex, but that's how I got it to work. Abc is outside any class. Xyz is a function in CNewDlg.void WINAPI Abc(LinkPtr pData) { ((CNewDlg*)AfxGetApp()->m_pMainWnd)->Xyz(pData);
<---I don't like this}
Thanks -
I have a fragment of code as an example, and I'm trying to figure out what it does and how.
void WINAPI CLeft::Abc(LinkPtr pData) { g_Spec().Xyz(pData); }
I know CLeft::CLeft is a global outside of any class. It receives callbacks from a server. I know Xyz is in a class. I know the pointer pData is being passed. I think both Abc and Xyz are defined in the same file. I'm not sure whatg_Spec().Xyz()
really is. I'm trying to figure out how and where one definesg_Spec().Xyz(pData)
so it can 1)be referenced by Xyz 2)be a class or within a class Anything look familiar? I really don't know if there is enough here to provide sufficient information. I am currently using the following and don't like it. It seems too complex, but that's how I got it to work. Abc is outside any class. Xyz is a function in CNewDlg.void WINAPI Abc(LinkPtr pData) { ((CNewDlg*)AfxGetApp()->m_pMainWnd)->Xyz(pData);
<---I don't like this}
ThanksOliver123 wrote:
I'm not sure what g_Spec().Xyz()really is.
From its name it semms to be a global, and from its use I think it could be a global function, returning the reference to a singelton-instance of a class providing a function called
Xyz
, which takes a parameter that very well could be aLinkPtr
.Oliver123 wrote:
void WINAPI Abc(LinkPtr pData) { ((CNewDlg*)AfxGetApp()->m_pMainWnd)->Xyz(pData); <---I don't like this }
Have you considered sending a user defined message?
Failure is not an option - it's built right in.