Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CppMath
- {
- public:
- CppMath(int arg1, int arg2,const CString &str);
- //Copy constructor
- CppMath(const CppMath &myCppMath);
- double Add(double arg1, double arg2);
- ....
- CString &GetTestString(void);
- private:
- int firstArg;
- int secondArg;
- CString testString;
- };
- CppMath::CppMath(int arg1, int arg2,const CString &str):
- firstArg(arg1),
- secondArg(arg2),
- testString(str)
- {
- }
- **//1. How do you create a C++/CLI wrapper for this constructor**
- CppMath::CppMath(const CppMath &myCppMath)
- {
- firstArg = myCppMath.firstArg;
- secondArg = myCppMath.secondArg;
- testString = myCppMath.testString;
- }
- double CppMath::Add(double arg1, double arg2)
- {
- return arg1 + arg2;
- }
- ...
- CString & CppMath::GetTestString()
- {
- return testString;
- }
- namespace CLRWrapper {
- public ref class CppMathWrapper
- {
- public:
- CppMathWrapper(void *cppMath); **//2. Not sure how to declare a wrapper for this native C++ constructor "CppMath(const CppMath &myCppMath);" **
- CppMathWrapper(int arg1, int arg2, String ^str);
- double Add(double arg1, double arg2);
- ...
- String ^GetTestString(void);
- private:
- CppMath *cppMath;
- };
- CLRWrapper::CppMathWrapper::CppMathWrapper(void *cppMath)
- {
- ??? //3. How to convert ccpMath to CppMath pointer type
- cppMath = new CppMath(cppMath);
- }
- CLRWrapper::CppMathWrapper::CppMathWrapper(int arg1, int arg2, String ^str)
- {
- cppMath = new CppMath(arg1, arg2, str);
- }
- double CLRWrapper::CppMathWrapper::Add(double arg1, double arg2)
- {
- return cppMath->Add(arg1, arg2);
- }
- ...
- String ^CLRWrapper::CppMathWrapper::GetTestString()
- {
- return (gcnew String(cppMath->GetTestString()));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement