Search code examples
visual-c++referencec++-cliinteropmixed-mode

Convert .Net ref (%) to native (&)


How can I convert a C++/CLI int %tmp to native C++ int &tmp?

void test(int %tmp)
{
    // here I need int &tmp2 for another pure C++ function call
}

Solution

  • void your_function(int *);
    void your_function2(int &);
    
    void test(int %tmp)
    {
        int tmp2;
        your_function(&tmp2);
        your_function2(tmp2);
        tmp=tmp2;
    }