473,385 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Operator overloading

VB .Net does support operator overloading, doesn't it? It seems like this
should overload binary addition, but VB doesn't recognize "Operator"

Public Shared Operator +(ByVal c1 as cnum, ByVal c2 as cnum) as cnum
' End of statement expected

End Operator

--

Jon Cosby

Please do not reply to this email address.
Nov 20 '05 #1
13 1759
Cor
Jon,

No VB.net in this versions does not support operator overloading, it will in
the next.

You can read for it in this newsgroup in a messagesthread from yesterday

Cor
VB .Net does support operator overloading, doesn't it? It seems like this
should overload binary addition, but VB doesn't recognize "Operator"

Public Shared Operator +(ByVal c1 as cnum, ByVal c2 as cnum) as cnum
' End of statement expected

End Operator

Nov 20 '05 #2
* "Jon Cosby" <qw****@nospam.net> scripsit:
VB .Net does support operator overloading, doesn't it? It seems like this
should overload binary addition, but VB doesn't recognize "Operator"

Public Shared Operator +(ByVal c1 as cnum, ByVal c2 as cnum) as cnum
' End of statement expected

End Operator


Wait for VS.NET 2004, VB.NET currently doesn't support operator
overloading.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
There's a section titled "Operator Overloading Usage Guidelines in Visual
Basic" in the documentation. What's that referring to?

Jon

"Cor" wrote:
Jon,

No VB.net in this versions does not support operator overloading, it will in the next.

You can read for it in this newsgroup in a messagesthread from yesterday

Cor
VB .Net does support operator overloading, doesn't it? It seems like this should overload binary addition, but VB doesn't recognize "Operator"

Public Shared Operator +(ByVal c1 as cnum, ByVal c2 as cnum) as cnum
' End of statement expected

End Operator


Nov 20 '05 #4
* "Jon Cosby" <qw****@nospam.net> scripsit:
There's a section titled "Operator Overloading Usage Guidelines in Visual
Basic" in the documentation. What's that referring to?


Can you post the link?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5
ms-help://MS.VSCC/MS.MSDNVS/cpgenref/html/cpconoperatoroverloadingusageguide
lines.htm

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OE**************@tk2msftngp13.phx.gbl...
* "Jon Cosby" <qw****@nospam.net> scripsit:
There's a section titled "Operator Overloading Usage Guidelines in Visual Basic" in the documentation. What's that referring to?


Can you post the link?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #6
* "Jon Cosby" <qw****@nospam.net> scripsit:
ms-help://MS.VSCC/MS.MSDNVS/cpgenref/html/cpconoperatoroverloadingusageguide
lines.htm


The document is talking about the .NET Framework and provides samples in
C++/C#:

<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconoperatoroverloadingusageguidelines.asp>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #7
You can actually implement operator overloading routines, but cannot use
them in VB.NET, well, you can, but not in the traditional sense. You need to
call the routines that implement operator overloading, instead of using the
actual operators.

The routines are defined as op_***

where *** is the type of operator to overload, e.g. op_Implicit etc

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eS**************@tk2msftngp13.phx.gbl...
* "Jon Cosby" <qw****@nospam.net> scripsit:
ms-help://MS.VSCC/MS.MSDNVS/cpgenref/html/cpconoperatoroverloadingusageguide lines.htm
The document is talking about the .NET Framework and provides samples in
C++/C#:

<http://msdn.microsoft.com/library/de...-us/cpgenref/h
tml/cpconoperatoroverloadingusageguidelines.asp>
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #8
Tom,

* "Tom Spink" <thomasdotspinkat@ntlworlddotcom> scripsit:
You can actually implement operator overloading routines, but cannot use
them in VB.NET, well, you can, but not in the traditional sense. You need to
call the routines that implement operator overloading, instead of using the
actual operators.

The routines are defined as op_***

where *** is the type of operator to overload, e.g. op_Implicit etc


That's what the article I referenced is saying.

;-)

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #9
Jon,
VB.NET 2002 & 2003 only supports indirectly consuming overloaded operators
by the method that Tom Spink & Herfried indicated.

As Herfried stated, you need to wait for Whidbey for VB.NET to support
creating & consuming overloaded operators.

For a preview of what it will look like see:

http://blogs.msdn.com/cambecc/archiv.../20/51265.aspx

Hope this helps
Jay
"Jon Cosby" <qw****@nospam.net> wrote in message
news:Bv*****************@newsread1.news.pas.earthl ink.net...
VB .Net does support operator overloading, doesn't it? It seems like this
should overload binary addition, but VB doesn't recognize "Operator"

Public Shared Operator +(ByVal c1 as cnum, ByVal c2 as cnum) as cnum
' End of statement expected

End Operator

--

Jon Cosby

Please do not reply to this email address.

Nov 20 '05 #10
Tom,
You can actually implement operator overloading routines,


No you can't. You can consume most operator functions defined in other
languages, but you can't define your own. Just giving it the right
name (the op_ prefix) isn't enough.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 20 '05 #11
Okay! Fair enough... but just out of interest... what is 'enough'?

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:OH**************@TK2MSFTNGP10.phx.gbl...
Tom,
You can actually implement operator overloading routines,


No you can't. You can consume most operator functions defined in other
languages, but you can't define your own. Just giving it the right
name (the op_ prefix) isn't enough.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 20 '05 #12
Tom,
Naming a VB.NET method op_Addition is not enough to allow C# to use the
overloaded operator.

When C# creates its overloaded + method a special IL attribute is placed on
the op_Addition method, this IL attribute can only be placed by compilers
(not angle braces, such as serializable).

For details on how overloaded operators are implemented at the IL level see:

http://msdn.microsoft.com/msdnmag/is...C/default.aspx

My initial tests in Whidbey show they are using the same naming convention
for matching operators, obviously operators such as Like have no C# & C++
equivalent.

Hope this helps
Jay

"Tom Spink" <thomasdotspinkat@ntlworlddotcom> wrote in message
news:ep**************@tk2msftngp13.phx.gbl...
Okay! Fair enough... but just out of interest... what is 'enough'?

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:OH**************@TK2MSFTNGP10.phx.gbl...
Tom,
You can actually implement operator overloading routines,


No you can't. You can consume most operator functions defined in other
languages, but you can't define your own. Just giving it the right
name (the op_ prefix) isn't enough.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Nov 20 '05 #13
Intriguing... Thanks :)

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:u2**************@TK2MSFTNGP09.phx.gbl...
Tom,
Naming a VB.NET method op_Addition is not enough to allow C# to use the
overloaded operator.

When C# creates its overloaded + method a special IL attribute is placed on the op_Addition method, this IL attribute can only be placed by compilers
(not angle braces, such as serializable).

For details on how overloaded operators are implemented at the IL level see:
http://msdn.microsoft.com/msdnmag/is...C/default.aspx

My initial tests in Whidbey show they are using the same naming convention
for matching operators, obviously operators such as Like have no C# & C++
equivalent.

Hope this helps
Jay

"Tom Spink" <thomasdotspinkat@ntlworlddotcom> wrote in message
news:ep**************@tk2msftngp13.phx.gbl...
Okay! Fair enough... but just out of interest... what is 'enough'?

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:OH**************@TK2MSFTNGP10.phx.gbl...
Tom,

>You can actually implement operator overloading routines,

No you can't. You can consume most operator functions defined in other
languages, but you can't define your own. Just giving it the right
name (the op_ prefix) isn't enough.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.



Nov 20 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Edward Diener | last post by:
Is there a way to override the default processing of the assignment operator for one's own __value types ? I realize I can program my own Assign method, and provide that for end-users of my class,...
34
by: Pmb | last post by:
I've been working on creating a Complex class for my own learning purpose (learn through doing etc.). I'm once again puzzled about something. I can't figure out how to overload the assignment...
16
by: gorda | last post by:
Hello, I am playing around with operator overloading and inheritence, specifically overloading the + operator in the base class and its derived class. The structure is simple: the base class...
2
by: pmatos | last post by:
Hi all, I'm overloading operator<< for a lot of classes. The question is about style. I define in each class header the prototype of the overloading as a friend. Now, where should I define the...
67
by: carlos | last post by:
Curious: Why wasnt a primitive exponentiation operator not added to C99? And, are there requests to do so in the next std revision? Justification for doing so: C and C++ are increasingly used...
3
by: karthik | last post by:
The * operator behaves in 2 different ways. It is used as the value at address operator as well as the multiplication operator. Does this mean * is overloaded in c?
5
by: Jerry Fleming | last post by:
As I am newbie to C++, I am confused by the overloading issues. Everyone says that the four operators can only be overloaded with class member functions instead of global (friend) functions: (), ,...
3
by: y-man | last post by:
Hi, I am trying to get an overloaded operator to work inside the class it works on. The situation is something like this: main.cc: #include "object.hh" #include "somefile.hh" object obj,...
9
by: sturlamolden | last post by:
Python allows the binding behaviour to be defined for descriptors, using the __set__ and __get__ methods. I think it would be a major advantage if this could be generalized to any object, by...
8
by: Wayne Shu | last post by:
Hi everyone, I am reading B.S. 's TC++PL (special edition). When I read chapter 11 Operator Overloading, I have two questions. 1. In subsection 11.2.2 paragraph 1, B.S. wrote "In particular,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.