Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. class CppMath
  2. {
  3. public:
  4.  
  5. CppMath(int arg1, int arg2,const CString &str);
  6. //Copy constructor
  7. CppMath(const CppMath &myCppMath);
  8. double Add(double arg1, double arg2);
  9. ....
  10. CString &GetTestString(void);
  11.  
  12. private:
  13. int firstArg;
  14. int secondArg;
  15. CString testString;
  16. };
  17.  
  18. CppMath::CppMath(int arg1, int arg2,const CString &str):
  19. firstArg(arg1),
  20. secondArg(arg2),
  21. testString(str)
  22. {
  23. }
  24.  
  25. **//1. How do you create a C++/CLI wrapper for this constructor**
  26. CppMath::CppMath(const CppMath &myCppMath)
  27. {
  28. firstArg = myCppMath.firstArg;
  29. secondArg = myCppMath.secondArg;
  30. testString = myCppMath.testString;
  31. }
  32. double CppMath::Add(double arg1, double arg2)
  33. {
  34. return arg1 + arg2;
  35. }
  36. ...
  37. CString & CppMath::GetTestString()
  38. {
  39. return testString;
  40. }
  41.  
  42. namespace CLRWrapper {
  43. public ref class CppMathWrapper
  44. {
  45. public:
  46. CppMathWrapper(void *cppMath); **//2. Not sure how to declare a wrapper for this native C++ constructor "CppMath(const CppMath &myCppMath);" **
  47. CppMathWrapper(int arg1, int arg2, String ^str);
  48. double Add(double arg1, double arg2);
  49. ...
  50. String ^GetTestString(void);
  51.  
  52. private:
  53. CppMath *cppMath;
  54.  
  55. };
  56.  
  57. CLRWrapper::CppMathWrapper::CppMathWrapper(void *cppMath)
  58. {
  59. ??? //3. How to convert ccpMath to CppMath pointer type
  60. cppMath = new CppMath(cppMath);
  61.  
  62. }
  63.  
  64. CLRWrapper::CppMathWrapper::CppMathWrapper(int arg1, int arg2, String ^str)
  65. {
  66. cppMath = new CppMath(arg1, arg2, str);
  67. }
  68.  
  69. double CLRWrapper::CppMathWrapper::Add(double arg1, double arg2)
  70. {
  71. return cppMath->Add(arg1, arg2);
  72. }
  73. ...
  74.  
  75. String ^CLRWrapper::CppMathWrapper::GetTestString()
  76. {
  77. return (gcnew String(cppMath->GetTestString()));
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement