Operator Overload - Whidbey

  • Thread starter Thread starter Genival Carvalho
  • Start date Start date
G

Genival Carvalho

Hello friends...
Inside my class how do to use explicit using Overloaded operator or use
default ?
Ex:
Dim x as Integer = A + B ' Use default + operator

Dim OV as integer = X + Z ' I will need use Overloaded + Operator ???


Thanks and sorry my bad English.
Regards
Genival Carvalho
 
Hi Genival,

Why did you put Whidbey in the title of your question, I wonder?

For the answer to your question lies in that word - Wait for Whidbey.

That's the sad fact. Operator overloading is on its way but it's not here
yet.

Regards,
Fergus
 
Genival,
Are you asking how do you do define Operator Overloading in Whidbey? Or how
do you use an overloaded Operator in Whidbey?

It might help if you tell us what types A, B, & Z are.

As Fergus pointed out, you will need to wait for Whidbey to do Operator
Overloading in VB.NET.

For details of how operator overloading will probably work in Whidbey see:

http://blogs.gotdotnet.com/cambecc/permalink.aspx/5de5a161-9150-4237-a751-127195cceeab

Note seeing as Whidbey is still a beta, the actual specifics may change.

Hope this helps
Jay
 
TankZ Guys...
I am waiting... but i will know ho do Operator overload will work.

Regards
Genival Carvalho.
 
* "Genival Carvalho said:
Inside my class how do to use explicit using Overloaded operator or use
default ?

You want to overload the operator for the Integer type?!
Ex:
Dim x as Integer = A + B ' Use default + operator

Dim OV as integer = X + Z ' I will need use Overloaded + Operator ???

What's the type of 'Z'?
 
The question is:
How do to instruct compiler to use Overloaded Operator version or use
default operator ?

Ex: Dim x as integer = A + B ' I need use overloaded version how to intruct
.....

Ex2: Dim P as integer = C + D ' At this point i need use default + operator

Thank you.
 
* "Genival Carvalho said:
How do to instruct compiler to use Overloaded Operator version or use
default operator ?

Ex: Dim x as integer = A + B ' I need use overloaded version how to intruct
....

Ex2: Dim P as integer = C + D ' At this point i need use default + operator

If you are using whidbey, why don't/didn't you post to the Whidbey alpha
groups? There will only be very few people with VB.NET Whidbey
experiences.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Dilbert's words of wisdom #18: Never argue with an idiot. They drag you down
to their level then beat you with experience.
 
Genival,
How do to instruct compiler to use Overloaded Operator version or use
default operator ?
Assuming that A, B, C, and D are integers, you do not instruct the compiler
to use an overloaded operator.

To define an overloaded operator the function needs to be in the class or
structure that the operator pertains to, at least one of the parameters need
to be of the class or structure that the overloaded operator is in.

So you cannot overload the + operator for integers, you can only overload
the operator for your own classes & structures

See the link I gave earlier.

Hope this helps
Jay

Genival Carvalho said:
The question is:
How do to instruct compiler to use Overloaded Operator version or use
default operator ?

Ex: Dim x as integer = A + B ' I need use overloaded version how to intruct
....

Ex2: Dim P as integer = C + D ' At this point i need use default + operator

Thank you.
 
Great...
Thank you.

Jay B. Harlow said:
Genival,
How do to instruct compiler to use Overloaded Operator version or use
default operator ?
Assuming that A, B, C, and D are integers, you do not instruct the compiler
to use an overloaded operator.

To define an overloaded operator the function needs to be in the class or
structure that the operator pertains to, at least one of the parameters need
to be of the class or structure that the overloaded operator is in.

So you cannot overload the + operator for integers, you can only overload
the operator for your own classes & structures

See the link I gave earlier.

Hope this helps
Jay
 
Back
Top