Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   how to declare a structure and a class interlinked (http://www.velocityreviews.com/forums/t280014-how-to-declare-a-structure-and-a-class-interlinked.html)

mosfet 12-15-2003 10:41 AM

how to declare a structure and a class interlinked
 
Hi,

I have some problems to write my class :

if I put the structure declaration before my class i have a compiler error
since my CHTTPServerCe is not yet known from the compiler but if I put it
after I have another error because inside my class I use my structure
(CloseConnection(LPREQUEST lpreq)). So how can I solve this problem

/*--------------------------------------------------------------------------
-------------
CONNECTION Structure
----------------------------------------------------------------------------
-----------*/
typedef struct tagREQUEST
{
CHTTPServerCE* pThis;
HANDLE hExit;
SOCKET Socket;
int nMethod;
DWORD dwConnectTime;
DWORD dwRecv;
DWORD dwSend;
HANDLE hFile;
TCHAR szFileName[_MAX_PATH];
}REQUEST, *LPREQUEST;


class CHTTPServerCE
{
public:
CHTTPServerCE();
virtual ~CHTTPServerCE();
int StartServer(short nPort);
int StopServer();
void CloseConnection(LPREQUEST lpReq);

TCHAR* m_szLogFile;
SOCKET m_sockServer;
HANDLE m_hevtStop; ///Handle of the thread stop event
HANDLE m_hThread;
USHORT m_nNumClient;

private:
void WriteLogFile(CString csLog);
void LogEvent(TCHAR* szPath, TCHAR* format, ...);
//void LogEvent(CString csPath, CString lpFormat, ...);
static DWORD WINAPI ListeningThread(LPVOID lpArg);
DWORD ListeningThread();
static DWORD WINAPI ClientThread(LPVOID lpArg);

};



if I put the connection structure before



lallous 12-15-2003 10:45 AM

Re: how to declare a structure and a class interlinked
 
"mosfet" <tricubes@wanadoo.fr> wrote in message
news:brk30g$tmi$1@news-reader3.wanadoo.fr...
> Hi,
>
> I have some problems to write my class :
>
> if I put the structure declaration before my class i have a compiler error
> since my CHTTPServerCe is not yet known from the compiler but if I put it
> after I have another error because inside my class I use my structure
> (CloseConnection(LPREQUEST lpreq)). So how can I solve this problem
>
>

/*--------------------------------------------------------------------------
> -------------
> CONNECTION Structure
> --------------------------------------------------------------------------

--
> -----------*/
> typedef struct tagREQUEST
> {
> CHTTPServerCE* pThis;
> HANDLE hExit;
> SOCKET Socket;
> int nMethod;
> DWORD dwConnectTime;
> DWORD dwRecv;
> DWORD dwSend;
> HANDLE hFile;
> TCHAR szFileName[_MAX_PATH];
> }REQUEST, *LPREQUEST;
>
>
> class CHTTPServerCE
> {
> public:
> CHTTPServerCE();
> virtual ~CHTTPServerCE();
> int StartServer(short nPort);
> int StopServer();
> void CloseConnection(LPREQUEST lpReq);
>
> TCHAR* m_szLogFile;
> SOCKET m_sockServer;
> HANDLE m_hevtStop; ///Handle of the thread stop event
> HANDLE m_hThread;
> USHORT m_nNumClient;
>
> private:
> void WriteLogFile(CString csLog);
> void LogEvent(TCHAR* szPath, TCHAR* format, ...);
> //void LogEvent(CString csPath, CString lpFormat, ...);
> static DWORD WINAPI ListeningThread(LPVOID lpArg);
> DWORD ListeningThread();
> static DWORD WINAPI ClientThread(LPVOID lpArg);
>
> };
>
>
>
> if I put the connection structure before
>
>

Hello,

Try to forward declare your class before the structure as:
class CHTTPServerCE; // forward declaration

--
Elias




All times are GMT. The time now is 11:54 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57