Overloading Operators in C++, exporting and Importing then in VB.NET

Working on DLLs, Operator overloading and Structures in C++ and VB.NET

Page 1 of 1

1 Replies - 2042 Views - Last Post: 26 January 2010 - 01:16 PM Rate Topic: -----

#1 Voulnet  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 17-January 10

Overloading Operators in C++, exporting and Importing then in VB.NET

Post icon  Posted 26 January 2010 - 11:51 AM

Howdy all, I have a weird situation. I have a C++ code that overloads the +,-,* operators and exports them in a .DLL file. Now, I want to import those overloaded operators from within VB.NET code. So it should be like this:

<DllImport("StructDLL.dll")> Public Shared Function 
 Operator +(ByVal a1 As A, ByVal a2 As A) As A
End Function


So what I'm trying to do above it just import the lovely overloaded operator + from the DLL.

Note that the operator is already overloaded from inside the DLL, so should I import it as a Function or as an Operator like this?

<DllImport("StructDLL.dll")> Public Shared 
  Operator +(ByVal a1 As A, ByVal a2 As A) As A
  End Operator


The overloaded plus operator is supposed to add structs. So the DLL is programmed to work on structs (C++) and I want to import it in VB.NET to work on Structures.

Is This A Good Question/Topic? 0
  • +

Replies To: Overloading Operators in C++, exporting and Importing then in VB.NET

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,500
  • Joined: 29-May 08

Re: Overloading Operators in C++, exporting and Importing then in VB.NET

Posted 26 January 2010 - 01:16 PM

And your question is?
Since it not a function, I would say the second. Best is to suck it a see.

You know you can also overload most of the operators in vb.net


Public Structure A
 Public X As Double
 Public Y As Double
 Overloads Shared Operator +(ByVal A1 As A, ByVal A2 As A) As A

 End Operator
End Structure


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1