更新时间:2022-10-15 15:19:29
试试这个:
  
pin_ptr < int > pp1 =
pnNum1 ;
pin_ptr < int > pp2 =
pnNum2 ;
NativeClassPtr->测试(pp1,pp2);
I am use C++/CLI to wrapper native C++ class. I'm use wrapper class in C#.
One the methods of the C++ native class has the following declaration:
void Test(int *pnNum1, int *pnNum2);
The method Test of the C++/CLI managed class has the following declaration:
void Тest([Out]interior_ptr<int> pnNum1, [Out]interior_ptr<int> pnNum2); The parameter pnNum1 and pnNum2 passing by reference.
void ManageClass::Test[Out]interior_ptr<int> pnNum1, [Out]interior_ptr<int> pnNum2)
{
NativeClassPtr->Test((int *)&pnNum1, (int *)&pnNum2); //did not work!!!
}
How do I pass a parameter by reference of the method Test NativeClassPtr->Test?
I have to convert to interior_ptr to pin_ptr to native_ptr. How to do this without using variables(pin_ptr an native).Try this:
pin_ptr<int> pp1 = pnNum1;
pin_ptr<int> pp2 = pnNum2;
NativeClassPtr->Test( pp1, pp2 );