EDN Admin
Well-known member
Hello everyone,
So, i have been working on a very basic "graphics" library ( just for learning purposes ) and a "graphics" library must contain some basic classes like Size, Point , Rectangle , Color etc.
So when coding the Size class , a dilemma came up :
Size is always a POSITIVE value ( as far as i know ) , so should i use unsigned int for x,y or just int ?
The answer should be easy, uint! But then i decided to consult at GDI+ and SDL Size classes, which turned out to useint.
Now i cant help but wonder : Do they use int because they are "bored" of typing unsigned int ? Do they use int because negative sizes are actually acceptable? If yes, why should a negative value be acceptable in my Size class?
My opinion is that i shouldnt accept invalid input! But i am not an experienced programmer, what do you people think on this?
TsopTsop
View the full article
So, i have been working on a very basic "graphics" library ( just for learning purposes ) and a "graphics" library must contain some basic classes like Size, Point , Rectangle , Color etc.
So when coding the Size class , a dilemma came up :
Size is always a POSITIVE value ( as far as i know ) , so should i use unsigned int for x,y or just int ?
The answer should be easy, uint! But then i decided to consult at GDI+ and SDL Size classes, which turned out to useint.
Now i cant help but wonder : Do they use int because they are "bored" of typing unsigned int ? Do they use int because negative sizes are actually acceptable? If yes, why should a negative value be acceptable in my Size class?
My opinion is that i shouldnt accept invalid input! But i am not an experienced programmer, what do you people think on this?
TsopTsop
View the full article