Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to call C++ class from C#
    primarykey
    data
    text
    <p>I suppose I have to create a managed C++ code to wrap the native C++. But I have the problem while trying to wrap an array used in function parameter whose type is defined in native C++. The native C++ code is as follows:</p> <pre><code>//unmanageCPP.h class __declspec(dllexport) unmanageMoney { public: unmanageMoney(int a, int b) { rmb = a; dollar = b; } unmanageMoney() { rmb = 0; dollar = 0; } int rmb; int dollar; }; class __declspec(dllexport) unmanageSum { public: //how to wrap this funciton? int addDollar(unmanageMoney a[], unmanageMoney b[]); }; //unmanageCPP.cpp #include "unmanaged.h" int unmanageSum::adddollar(unmanageMoney a[], unmanageMoney b[]) { return a[0].dollar + b[0].dollar; } </code></pre> <p>Could anyone tell me how to write the manageCPP.h? Thanks very much!</p> <p><strong>Update</strong></p> <p>I compose the manageCPP.h as follows, but I don't know how to write addDollar()</p> <pre><code>//first, I wrap the class unmanageMoney for use in manageSum::addDollar() public ref class manageMoney { private: unmanageMoney* mMoney; public: unmanageMoney getMoney() { return *mMoney; } manageMoney(int a, int b) { mMoney = new unmanageMoney(a, b); } ~manageMoney() { delete mMoney; } }; public ref class manageSum { // TODO: Add your methods for this class here. private: unmanageSum *mSum; public: manageSum() { mSum = new unmanageSum(); } ~manageSum() { delete mSum; } //it must be wrong if I code like this, for unmanageSun::adddollar() only // receives unmanageMoney as arguments. So what should I do? int adddollar(manageMoney a[], manageMoney b[]) { return mSum-&gt;adddollar(a, b); } }; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload