2 Replies - 924 Views - Last Post: 23 August 2016 - 02:11 PM

#1 goder  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 04-March 16

wrapper class CLR

Posted 23 August 2016 - 10:30 AM

hello, I need a wrapper class to connect c++ to C# but it gives me 5 errors, first one says: 'st' : 'struct'type redefinition.
compiler sees the link but this error gets annoying.

in header:

using namespace System;

namespace CppWrapper {

public ref class CppWrapperClass
{
public:


CppWrapperClass();
//~CppWrapperClass();
int getSum();
int sum;

private:

st * p = new st;
};
}

in source file:

CppWrapper::CppWrapperClass ::CppWrapperClass()
{

}

int CppWrapper::CppWrapperClass::getSum()
{
int sum;
sum = p->get();
return sum;

}


in c++:

#include<iostream>
using namespace std; 
struct st {
int ma[3] = { 1,2,3 };
int get() { return ma[2]; }
};

int main() {

return 0;
}

thank you!

This post has been edited by Atli: 23 August 2016 - 10:57 AM
Reason for edit:: Please use [code] tags when posting code.


Is This A Good Question/Topic? 0
  • +

Replies To: wrapper class CLR

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13493
  • View blog
  • Posts: 53,899
  • Joined: 12-June 08

Re: wrapper class CLR

Posted 23 August 2016 - 11:10 AM

Please copy/paste your error messages here.
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5898
  • View blog
  • Posts: 20,137
  • Joined: 05-May 12

Re: wrapper class CLR

Posted 23 August 2016 - 02:11 PM

Moving to C++/CLI...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1