473,569 Members | 2,901 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
(CloseConnectio n(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(sho rt 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(CS tring csLog);
void LogEvent(TCHAR* szPath, TCHAR* format, ...);
//void LogEvent(CStrin g csPath, CString lpFormat, ...);
static DWORD WINAPI ListeningThread (LPVOID lpArg);
DWORD ListeningThread ();
static DWORD WINAPI ClientThread(LP VOID lpArg);

};

if I put the connection structure before
Jul 22 '05 #1
1 2064
"mosfet" <tr******@wanad oo.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
(CloseConnectio n(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(sho rt 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(CS tring csLog);
void LogEvent(TCHAR* szPath, TCHAR* format, ...);
//void LogEvent(CStrin g csPath, CString lpFormat, ...);
static DWORD WINAPI ListeningThread (LPVOID lpArg);
DWORD ListeningThread ();
static DWORD WINAPI ClientThread(LP VOID 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
3483
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 in the structure pointed to by the index will be called with various data. Say i have a couple of functions: int func1(int , int);
8
1952
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 referring to these controls: Set main = ! Set MySubform = !!. Set Quantity = !!..
8
14467
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 me do this saying that I can't declare a structure with fixed size arrays. Yet the book I'm looking at shows
5
4599
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 wPid As Integer public vDriverVersion As Long
4
1221
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
10150
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". */ unsigned short int array_size = 25; /*Declare an array named "numbers" using the variable initialized above. */ unsigned short int numbers;
5
2357
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
2119
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 declaration is as below. The problem is in "struct _WLAN_AVAILABLE_NETWORK_LIST", it declared "WLAN_AVAILABLE_NETWORK Network;". I think which means a...
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) <StructLayout(LayoutKind.Explicit)_ Structure XStructure <FieldOffset(0)Dim A As Single
0
7693
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7917
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.