Exposing an ISO C++ class to C#

后端 未结 3 1654
北荒
北荒 2021-02-19 07:01

I need to expose some C++ classes to C# (I am building on Linux, using mono, so COM is not an option)

The evidence I have gathered so far suggests that the best way to a

3条回答
  •  攒了一身酷
    2021-02-19 07:21

    you had to write a c++ managed wraper around your iso c++ class like this

     public ref class MyWrapper
        {
        public:
        MyWrapper (void)
        {
        pObj = new CMyUnmanagedClass();
        }
        ~MyWrapper (void)
        {
        delete pObj;
        }
        int foo(void)
        {
        //pass through to the unmanaged object
        return pObj->foo();
        }
        private:
        CMyUnmanagedClass* pObj;
        };
    

    i hope this help regards

提交回复
热议问题