473,503 Members | 3,739 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jul 22 '05 #1
1 2060
"mosfet" <tr******@wanadoo.fr> wrote in message
news:br**********@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
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3472
by: Mackan | last post by:
Hi! I'm trying to declare a structure that will be including pointers to functions. These structures in turn will be pointed to in an array and depending on a index value that specific function...
8
1946
by: Johm | last post by:
In my codes i am often referring to one and the same controls.Is it possible to declare these controls only once and then insert them in all my functions and subs? For example, i am often...
8
14461
by: John Dann | last post by:
Trying to declare a structure that will contain a couple of fixed-size arrays. I'm trying eg: Structure IndexRecord Dim testarray(16) as Byte etc End Structure But vb.net is refusing to let...
5
4595
by: Sakharam Phapale | last post by:
Hi All, How to declare the following statement in following structure. szPname As String * MAXPNAMELEN Public Structure MIXERCAPS public wMid As Integer public ...
4
1217
by: Thomas | last post by:
I tried the following: Public Class ClassA Public Class ClassB Private myName As String Private myBirthday As Date Public Property Birthday() As Date Get Return myBirthday
8
10145
by: redefined.horizons | last post by:
I would like to have an array declaration where the size of the array is dependent on a variable. Something like this: /* Store the desired size of the array in a variable named "array_size". */...
5
2350
by: sharat | last post by:
hi all can any body tell how to declare the structure pointer within a class. i have written the following program but gettin error. #include<iostream> using namespace std;
1
2111
by: peary | last post by:
Hi, everyone, I'm writing a program to discover wireless network using Windows Native Wifi API & VB.net. I have to declare the windows API in my VB.net program. The original windows...
0
422
by: Joe HM | last post by:
Hello - I have a *.dll that was compiled from Ada. The following declaration and Structure is working ... Declare Sub XXX Lib "X.dll" (ByRef XState As XStructure) ...
0
7192
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7064
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7445
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4665
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
369
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.