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

void (Foo::^p)()=&Foo::bar; // won't compile

P: n/a
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
}
};
Mar 20 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Ray Tayek" <rt*******@spam.comcast.net> wrote in message
news:MP***********************@msnews.microsoft.co m...
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
}
};


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();
Mar 21 '06 #2

P: n/a
In article <up**************@TK2MSFTNGP10.phx.gbl>, NO****@heege.net
says...
"Ray Tayek" <rt*******@spam.comcast.net> wrote in message
news:MP***********************@msnews.microsoft.co m...
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
}
};


instead of your managed function pointer, you should define

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
Mar 23 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.