void (Foo::*)() to a void (*)() typecast problems
Read down. How do I make that assignment there?
Thanks
-eurijk!
Thanks
-eurijk!
#include [Error: Irreparable invalid markup ('<stdio.h>') in entry. Owner must fix manually. Raw contents below.]
Read down. How do I make that assignment there?
Thanks
-eurijk!
<code>
#include <stdio.h>
class Foo {
private:
int instance;
public:
Foo( int instance) {
Foo::instance = instance;
}
void bar( void) {
printf("This instance is %d\n", instance);
}
};
int main( void) {
Foo *foo[2];
foo[0] = new Foo( 626);
foo[1] = new Foo( 747);
void (Foo::*fnptr)( void) = &Foo::bar;
(foo[0]->*fnptr)();
(foo[1]->*fnptr)();
void (*fn)();
//===
// Help here! How do I make this assignment?
// fn = foo[0]->*fnptr;
delete foo[1];
delete foo[0];
}
</code>
Thanks
-eurijk!
<code>
#include <stdio.h>
class Foo {
private:
int instance;
public:
Foo( int instance) {
Foo::instance = instance;
}
void bar( void) {
printf("This instance is %d\n", instance);
}
};
int main( void) {
Foo *foo[2];
foo[0] = new Foo( 626);
foo[1] = new Foo( 747);
void (Foo::*fnptr)( void) = &Foo::bar;
(foo[0]->*fnptr)();
(foo[1]->*fnptr)();
void (*fn)();
//===
// Help here! How do I make this assignment?
// fn = foo[0]->*fnptr;
delete foo[1];
delete foo[0];
}
</code>
