MARCO

W

Wei-Chao Hsu

Hi,


I read a Marco definition in a source file, which is shown below.


#define BEGIN_EVENT_TABLE(theClass, baseClass) \
const wxEventTable theClass::sm_eventTable = \
{ &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] };

Because I am not a C++ expert, I don't understand the meaning of the
definition. Why does two variables, baseClass::sm_eventTable and
theClass::sm_eventTableEntries[0], appear in the braces at the same time.
Which value is assigned to theClass::sm_eventTable. Is there anyone could
explain for me? Thank you!



Dennis
 
R

Rob Williscroft

Wei-Chao Hsu wrote in
I read a Marco definition in a source file, which is shown below.
s/Marco/Macro/g



#define BEGIN_EVENT_TABLE(theClass, baseClass) \
const wxEventTable theClass::sm_eventTable = \
{ &baseClass::sm_eventTable,
&theClass::sm_eventTableEntries[0] };

Because I am not a C++ expert, I don't understand the meaning of the
definition. Why does two variables, baseClass::sm_eventTable and
theClass::sm_eventTableEntries[0], appear in the braces at the same
time. Which value is assigned to theClass::sm_eventTable. Is there
anyone could explain for me? Thank you!

theClass::sm_eventTable is an agragate and bothe values in the braces
get assigned to it.

A simple example:

#include <iostream>

struct XY
{
int x;
int y;
};

XY xy = { 1, 2 };

int main()
{
std::cerr << xy.x << '\n';
std::cerr << xy.y << '\n';
}

The output is:
1
2

HTH.

Rob.
 
J

Jeffrey Schwab

Wei-Chao Hsu said:
#define BEGIN_EVENT_TABLE(theClass, baseClass) \
const wxEventTable theClass::sm_eventTable = \
{ &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] };
Because I am not a C++ expert, I don't understand the meaning of the
definition. Why does two variables, baseClass::sm_eventTable and
theClass::sm_eventTableEntries[0], appear in the braces at the same
time. Which value is assigned to theClass::sm_eventTable. Is there
anyone could explain for me? Thank you!


POLO!

If Rob's excellent example didn't clear help, try this:

http://www.devx.com/getHelpOn/Article/16039/0/page/3


-Jeff
 
W

Wei-Chao Hsu

Thanks for your help. I have understood.
Wei-Chao Hsu said:
#define BEGIN_EVENT_TABLE(theClass, baseClass) \
const wxEventTable theClass::sm_eventTable = \
{ &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] };
Because I am not a C++ expert, I don't understand the meaning of the
definition. Why does two variables, baseClass::sm_eventTable and
theClass::sm_eventTableEntries[0], appear in the braces at the same
time. Which value is assigned to theClass::sm_eventTable. Is there
anyone could explain for me? Thank you!


POLO!

If Rob's excellent example didn't clear help, try this:

http://www.devx.com/getHelpOn/Article/16039/0/page/3


-Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top