Here is the exact error message on compilation:
error C3352: 'double MyNamespace::MyRefClass::MyFunction(const std::vector<_Ty> &,std::vector<_Ty> &,void *)' : the specified function does not match the delegate type 'double (const std::vector<_Ty> &,std::vector<_Ty> &,void *)'
MyFunction
is a private function in the reference class MyRefClass
The quoted error shows up when I try to create an instance of the private delegate MyDelegate
, declared in the same reference class, with the code:
MyDelegate^ del = gcnew MyDelegate(&MyRefClass::MyFunction);
As far as I can tell, the signatures of the function MyFunctionWrapper
matches the delegate, so I'm not sure what is causing the error.
For completeness, the (private) function signature is:
double MyFunction(const std::vector<double> &x, std::vector<double> &grad, void *data)
and the (private) delegate declaration is:
delegate double MyDelegate(const std::vector<double> &x, std::vector<double> &grad, void *data);
I don't see the word static
in your method signature. If the method isn't static, you need to pass the object to the delegate constructor. Try this:
MyDelegate^ del = gcnew MyDelegate(this, &MyRefClass::MyFunction);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With