VC++ 2005 Question

Hi,

I am trying to use the code like the one described below......


namespace MyPhone
{
public class ref phone
{
.......

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
callFunc();
}

public: void callFunc()
{
tryThis(NULL, proc, NULL); //proc is another function it has to call - Error
}

public: proc(void* p1, void* p2, void* p3)
{
....
}

....
};
}

The above code gives me this error:

error C3867: 'MyPhone:hone:roc': function call missing argument list; use '&MyPhone:hone::EventProc' to create a pointer to member

can anyone please help me resolve this error. I tried creating delegates as per msdn, but I guess, I am losing some syntax.

[808 byte] By [bhaskar27in] at [2007-12-24]
# 1

The errors you describe can't be from the code above as the variable names don't appear in the snippet. Please show us the real code otherwise we'll be only guessing.

JonathanCaves-MSFT at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual C++ 2005 Express Edition...
# 2

Thank You for your reply,

However, I am sorry, the code snippet I posted had some mistakes....the real code snippet is as follows....

namespace MyPhone
{
public class ref phone
{
.......

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
callFunc();
}

public: void callFunc()
{
tryThis(NULL, proc, NULL); //proc is another function it has to call - Error
}

public: proc(void* p1, void* p2, void* p3)
{
....
}

....
};
}

The above code gives me this error:

error C3867: 'MyPhone:phone:proc': function call missing argument list; use '&MyPhone:phone::proc' to create a pointer to member

and when I use &MyPhone:phone:proc, it gives me this error :

error C3374: can't take address of 'MyPhone::phone:proc' unless creating delegate instance

bhaskar27in at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual C++ 2005 Express Edition...
# 3
Do what the error suggests, and create a delegate. Since you are working with C++/CLI here, managed clases can't take function pointers, you need to use delegates instead.
crescens2k at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual C++ 2005 Express Edition...
# 4

I am not that great with VC++ .Net, can you please tell me how to create a delegate in VC++ .Net.

It will be of great help.

Thank You in advance for your time and effort.

bhaskar27in at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual C++ 2005 Express Edition...