Note that there are some explanatory texts on larger screens.

plurals
  1. POerror C2664 cannot convert parameter 1 from 'std::string (__thiscall ClassName::* )(std::string)' to 'std::string (__cdecl *)(std::string)
    text
    copied!<p>I'm making a unmanaged application to handle an event fired in c# here. FYI:: I want to handle a custom event when my Name property in C# class is changed. I have gone through the following links:</p> <p><a href="http://www.cs.wustl.edu/~schmidt/PDF/C++-ptmf4.pdf" rel="nofollow">Explanation about passing pointer to member function as parameter</a> </p> <p><a href="http://www.questionhub.com/StackOverflow/1540859" rel="nofollow">Something similar to my problem.But couldn't understand the solution</a></p> <p>Now, In NativeApp.cpp,<em>I have a member function which is passed as a function pointer as parameter in a method present in the c++/CLI wrapper</em></p> <pre><code>//NativeApp.cpp std::string Class1::FunctionToBePointed(std::string msg) { return msg; } void Class1::NativeMethod() { UnmanagedWrapperClass* unmanagedWrapperClass=new UnmanagedWrapperClass(); unmanagedWrapperClass-&gt;WrapperMethod(&amp;Class1::FunctionToBePointed,"Hello") } </code></pre> <p>In Wrapper.h, </p> <pre><code>//Wrapper.h class __declspec(dllexport) UnmanagedWrapperClass { boost::signals2::signal&lt;void(std::string)&gt;signalEvent; void WrapperMethod(std::string (*GetCallBack)(std::string),std::string value); } </code></pre> <p>When I call the WrapperMethod from NativeApp.cpp, </p> <ol> <li><p>I subscribe my EventHandlerWrapper to a c# event</p></li> <li><p>connect the function pointer to my boost signal signalEvent.</p></li> <li><p>Set the Name property of the CSharp Class</p> <p>When the Name Property is set, c# event is fired, EventHandlerWrapper method in Wrapper.cpp is executed.Looks like this::</p> <p>void EventHandlerWrapper(string value)</p> <pre><code>{ if(signalEvent.connected()) </code></pre> <p>{ signalEvent(value); }</p></li> </ol> <p>For some reasons I can't make my FunctionToBePointed(std::string) method as a non-member function.</p> <p>P.S:: All ears for any other design approach.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload