473,326 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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

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
2 1277
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Alex Vinokur | last post by:
Is this approach safe? class Foo { // Stuff }; void func1 (void *) { // Do something
13
by: Old Wolf | last post by:
I have some code that has in the header file: void foo( char bar ); and in the source file: void foo( bar ) char bar; { /* etc. */ } The compiler (with many warnings enabled) warns that...
3
by: bingfeng | last post by:
hello, anyone else can explain why following codes give wrong result while compiler accept it still? int & foo() {} int main() { int x = foo; std::cout << x << std::endl; }
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.