Pointer Error
Jun 13, 2012 at 7:20am UTC
This is mine COM.H
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
typedef class CFINetCom
{
public :
HANDLE m_hReplyMsg;
private :
DWORD Status;
int ServerPort;
char * ServerIP;
HANDLE hThread;
HANDLE hListenThread;
HANDLE heThreadClose;
HANDLE hNewMess;
HANDLE ConnectEvent;
HANDLE ListenEvent;
SOCKET ConnectSock;
SOCKET ListenSock;
CRITICAL_SECTION MessageQueueCS;
CRITICAL_SECTION VarCS;
PMESSAGENODE MessageQueueFront;
PMESSAGENODE MessageQueueBack;
int m_iStatus;
PMESSAGENODE m_TempMessageQueueFront;
PMESSAGENODE m_TempMessageQueueBack;
// thread
static DWORD WINAPI ServerConnectThread(CFINetCom* MyServ);
void DeleteMessageQueue(void );
DWORD inline RetFatalErr(DWORD Err);
} CFINetCom, *pCFINetCom;
This is mine pmain.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include"COM.h"
class CTIMSStreamerDlg
{
public :
pCFINetCom m_FINetCom;
void StartConnectionThread();
public :
//Threads
static DWORD WINAPI MessageHandleThread(CTIMSStreamerDlg* pStreamerDlg);
static DWORD WINAPI VideoStatusThread(CTIMSStreamerDlg* pStreamerDlg);
static DWORD WINAPI ConnectionThread(CTIMSStreamerDlg* pStreamerDlg);
static DWORD WINAPI MessageReplyThread(CTIMSStreamerDlg* pStreamerDlg);
}b;
this is mine pmai.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include"pmain.h"
#include"com.h"
HANDLE m_hNewMsg;
int main()
{
Createini();
m_hNewMsg=CreateEvent(NULL, FALSE, FALSE, NULL);
if (m_hNewMsg == NULL)
{
printf("CreateEvent failed (%d)\n" , GetLastError());
return 1;
}
m_FINetCom = new CFINetCom(m_hNewMsg);
I am getting an error that m_FINetCom is
undefined although i have included the header file too,why is it so?
Jun 13, 2012 at 10:02am UTC
m_FINetCom is a member of CTIMSStreamerDlg, and it should be private. It should be initialised in the class constructor and released in the destructor.
Please do not write code like:
1 2 3 4
typedef class CFINetCom
{
//...
} CFINetCom, *pCFINetCom;
If you must typedef the pointer, do:
1 2 3 4 5 6
class CFINetCom
{
//...
};
typedef CFINetCom* PCFINetCom;
And even worse, never do this:
1 2 3 4
class CTIMSStreamerDlg
{
//...
}b;
Instead do:
1 2 3 4 5 6
class CTIMSStreamerDlg
{
//...
};
CTIMSStreamerDlg b;
Topic archived. No new replies allowed.