Hey! i need help with a code plz.

FlyBoy

Well-known member
Joined
Sep 6, 2004
Messages
106
i cant figure out...whats wrong in this code:
Code:
		static void Main(string[] args)
		{
			YYY t = new YYY();
			t.I =10;
			YYY f = new YYY();
		    f.I =50;
			YYY c;
			c=t+f;
		
		}
	}

	public class YYY
	{
		public int I
		{
			get { return i; }
			set {i=value; }
		}
		private int i;
		public static YYY operator+(YYY a,YYY b)
		{
		   YYY z = new YYY(a.I + a.I);
           return z;
		}
	}

it gives the following Error:"No overload for method YYY takes 1 arguments"

:confused: :confused: :o
 
I think you need to overload = for that to work, because of the line "c=t+f". You should have had a warning, I believe...

-ner
 
Code:
YYY z = new YYY(a.I + a.I);
YYY doesnt have a constructor that takes an integer.

you will need to add the following
Code:
public YYY()
{
}

public YYY(int value)
{
         i = value;
}
 
HJB417 said:
Code:
YYY z = new YYY(a.I + a.I);
YYY doesnt have a constructor that takes an integer.

you will need to add the following
Code:
public YYY()
{
}

public YYY(int value)
{
         i = value;
}
ohh now i see!!! i forgot the constructor......thanks for the help! ;)
 
Back
Top