hi, trying to make an array of function pointers to make delegates with.
but the compiler does not like: void (Foo::^p)()=&Foo::bar;
i did find an article that showed how to convert a delegate to a
function pointer, but i sorta want to go the other way around.
thanks
class Foo { public: void bar() {} };
class Baz {
void qux() {
void (Foo::*p)()=&Foo::bar; // works fine
}
};
ref class RFoo { void bar() {} };
ref class RBaz {
void qux() {
void (Foo::^p)()=&Foo::bar; // C2589 C2143 C2059
}
};
> hi, trying to make an array of function pointers to make delegates with.
> but the compiler does not like: void (Foo::^p)()=&Foo::bar;
[quoted text clipped - 16 lines]
> }
> };
instead of your managed function pointer, you should define
delegate void MyDelegate();
Once you have done that, you can instantiate it:
MyDelegate^ d = gcnew MyDelegate(&RFoo::bar);
Once you have instantiate it, you can invoke it:
d->Invoke();
Ray Tayek - 23 Mar 2006 04:13 GMT
> > hi, trying to make an array of function pointers to make delegates with.
> > but the compiler does not like: void (Foo::^p)()=&Foo::bar;
[quoted text clipped - 20 lines]
>
> delegate void MyDelegate(); ... you can invoke it:
yes, that works fine. i was hoping to initialize an array of function
pointers to use to create the delegate.
thanks