I have this function in C++:
struct MyObject
{
}
testAlgorithm(array<String^>^ algorithms, MyObject^ myObject)
I got this problem complaining about MyObject:
error C3699: ‘^’ : cannot use this indirection on type ‘MyObject’
But that is not the case with array<String^>^
Why is that and how to fix it?
In another situation, if i do it:
testAlgorithm(array<String^>^ algorithms, MyObject myObject)
Then in C#, I have to call:
testAlgorithm(string[] algorithms, MyObject *myObject);
I construct the MyObject in C# and declare it but how to pass it to testAlgorithm as: *myObject in C#?
Thanks in advance.
You cannot use the
^onMyObjectbecause it is not a managed class. To declare it as managed struct (that will, by the way be copied if it is passed as parameter), you would need to usevalue structinstead ofstruct.If you want your object to be passed as a reference (without copying, which is probably what you want), you should declare it as
ref class.