I wanted to show a problem I’m having while invoking functions of an instantiated class in C++.
I’m using a separate thread to listen to a TCP socket, so when data comes, I want to call a function to start doing tasks. I’m using process.h
library and _beginthread(socket_init,0,NULL);
to start the thread with socket_init()
function, which starts the listener.
To put you into situation, right before the thread initialization call, I have this:
CPhoneDlg dlg = new CPhoneDlg;
m_pMainWnd = &dlg;
This class has this function declared:
CTapiLine* CPhoneDlg::GetActiveLine() {...}
So the point of all this, is to be able to call GetActiveLine()
from the function that is being executed in the separate thread.
For that I tried to do this:
CTapiLine* line = dlg.GetActiveLine();
But it just doesn’t know what dlg
is, showing "identifier not declared" when I try to compile the code.
Is there any way to make dlg
object visible so its methods become "invokable" by the separate thread?