How to pass a managed link to unmanaged code in C ++ / CLI?

I use C ++ / CLI only for the unit test of unmanaged C ++ code in VS2010. I switched the compiler to / clr and used unmanaged code from a static library.

I have a simple intproperty in my test class. I would like to pass this as const int &functions in native C ++. But it cannot compile, and I found out about it because you cannot mix such links.

How to do this, I tried to follow and work, but is there a better way?

[TestClass]
public ref class MyTestClass
{
private:
    int _my_property;
public:

    [TestMethod]
    void MyTestMethod()
    {
        MyNativeClass c;
        // c.SomeMethod(_my_property) this doesn't work

        int i = _my__property;
        c.SomeMethod(i) // this works
    }
}
+3
source share
1 answer

++ sugare . ++ , CLI . , .

SO: ++/CLI ++

2

, ( @Tergiver @DeadMG ). wiki , .

+4

All Articles