Topic: Pointer to member question
Author: oklein@smallo.ruhr.de (Olaf Klein)
Date: 30 Nov 1994 23:31:07 +0100 Raw View
Hello,
The following code failes to link under Watcom C++ 10.0a, although I
think, the code is alright (I set main to winMain and tried to link
it under MS-Windows, but that should not matter !?) :
### ptom.c ###
#include <stdlib.h>
#include <string.h>
int
main(void)
{
return 0;
}
class X {
protected:
void foo(void);
public:
X(const char* const);
void bar(void);
};
X::X(const char* const)
{
}
void
X::foo(void)
{
}
struct table {
const char* str;
void (X::*func)(void);
};
void X::bar(void)
{
static table Table[] = {
{ "Foo", &X::foo }, // Is this correct?
// I did as shown in Stroustrup...
{ 0, 0 }
};
}
X x("bar");
### eof ###
--
Es gibt nicht einmal einen logischen Grund, am Leben zu bleiben. Aber der
Instinkt sagt es uns, und daher wollen wir es. [Poul Anderson]