Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 09-27-2004, 09:48 PM   #1 (permalink)
sureshkumar_kc
Registered User
 
sureshkumar_kc's Avatar
 
Join Date: Sep 2004
Posts: 12
sureshkumar_kc is on a distinguished road
C# member function

Can we override the operate overloading function in C# ?
sureshkumar_kc is offline   Reply With Quote
Old 09-27-2004, 10:08 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
could you try to ask that one more time? i'm not sure what you mean.

c# does support overloading, .. have you tried this? if so, are you getting errors?
__________________
Mike
sde is offline   Reply With Quote
Old 10-15-2004, 02:08 AM   #3 (permalink)
RobertStout
Registered User
 
RobertStout's Avatar
 
Join Date: Oct 2004
Location: Dank cellar
Posts: 18
RobertStout is on a distinguished road
Overloading operators to working with operands of custom class/structs. In this instance the user defined ComplexNumber type.

Code:
// overload the addition operator
public static ComplexNumber operator + ( ComplexNumber lhs, ComplexNumber rhs )
{
// return new ComplexNumber 
return new ComplexNumber( lhs.Real + rhs.Real, lhs.Imaginary + rhs.Imaginary );
}
Code:
ComplexNumber x = new ComplexNumber();
ComplexNumber y = new ComplexNumber();
ComplexNumber z = x + y;
RobertStout is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
operate overloading member function in C# sureshkumar_kc MS Technologies ( ASP, VB, C#, .NET ) 2 10-15-2004 02:36 AM
edit? anon Lounge 10 11-21-2002 03:02 PM


All times are GMT -8. The time now is 04:47 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting