Overlaoding, when and where to use?
View Single Post
10-28-2009, 01:31 AM
Join Date: Sep 2007
Overloading is for ambiguous functions. If you have a function with a lot of parameters that can do a lot of things, you may want other functions with less arguments that do less things. When I write overloaded functions they almost always use that "main" function with only what I need transferred over and other constant factors automated.
For example, one program I wrote had a circle drawing function. The circle could be an RGB color and at any given position on the screen. It could also have a border around it that is as wide as you want and any RGB color, same as a center. This is a lot of arguements, I had overloads to make a simple solid color circle where it only asks for the R,G,B,x and y values and fills the rest with zeros. That way you don't have to specify six zeros every time you want a solid circle.
The Following User Says Thank You to Village Idiot For This Useful Post:
View Public Profile
Send a private message to Village Idiot
Find More Posts by Village Idiot