Hey! i need help with a code plz.

FlyBoy

Centurion
Joined
Sep 6, 2004
Messages
106
i cant figure out...what's 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
 
Code:
YYY z = new YYY(a.I + a.I);
YYY doesn't 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 doesn't 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