[Mono-list] Question about C#
Ricardo Kirkner
mono@kirkner.com.ar
Mon, 9 Sep 2002 23:15:18 -0300
This is a multi-part message in MIME format.
------=_NextPart_000_002B_01C25856.C31C51C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I am sorry to bother the list with this question, but I could not find a =
satisfying answer anywhere.
My question regards overloading operators. As far as I know, if you want =
to overload some operator, it must be public and static.
1. I dont understand why this have to be that way
2. If I want to overload the ++ operator in a class that I dont want to =
be public, but internal or private, how can I prevent someone from =
accessing a method (the ++ operator) that has been defined public?
Another question is:
Since you can not overload the =3D operator, how can you redefine the =
assignement without using a copy constructor like=20
Class1(Class1 c) { /* data and methods */ }
With regards, and hoping someone can give me a hint
Ricardo Kirkner
------=_NextPart_000_002B_01C25856.C31C51C0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2719.2200" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I am sorry to bother the list with this =
question,=20
but I could not find a satisfying answer anywhere.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>My question regards overloading =
operators. As far=20
as I know, if you want to overload some operator, it must be public and=20
static.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>1. I dont understand why this have to =
be that=20
way</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>2. If I want to overload the ++ =
operator in a class=20
that I dont want to be public, but internal or private, how can I =
prevent=20
someone from accessing a method (the ++ operator) that has been defined=20
public?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Another question is:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Since you can not overload the =3D =
operator, how can=20
you redefine the assignement without using a copy constructor like =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> Class1(Class1 c) { =
/* data and=20
methods */ }</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>With regards, and hoping someone can =
give me a=20
hint</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Ricardo Kirkner</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV></BODY></HTML>
------=_NextPart_000_002B_01C25856.C31C51C0--