FlyBoy Posted October 25, 2004 Posted October 25, 2004 i cant figure out...what's wrong in this 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 Quote
*Experts* Nerseus Posted October 25, 2004 *Experts* Posted October 25, 2004 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 Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
HJB417 Posted October 26, 2004 Posted October 26, 2004 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 public YYY() { } public YYY(int value) { i = value; } Quote
FlyBoy Posted October 29, 2004 Author Posted October 29, 2004 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 public YYY() { } public YYY(int value) { i = value; } ohh now i see!!! i forgot the constructor......thanks for the help! ;) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.