By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,911 Members | 1,137 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,911 IT Pros & Developers. It's quick & easy.

MARCO

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Wei-Chao Hsu wrote in news:bs********@netnews.hinet.net:

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.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #2

P: n/a

Wei-Chao Hsu wrote:
#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

Jul 22 '05 #3

P: n/a
Thanks for your help. I have understood.
Wei-Chao Hsu wrote:
> #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

Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.