Archived

This topic is now archived and is closed to further replies.

InsaneX

Function Overloading

Recommended Posts

InsaneX    122
I was wondering if there was an easier way to overload a function to accept different types of data (int, float), when the type wouldn''t matter. An example of this would be a memory manager, you have a DeAllocate() function, no matter what type of pointer is passed, you want to just delete it, and it won''t matter what type. (this is assuming no arrays)

Share this post


Link to post
Share on other sites
InsaneX    122
Thank you very much Desert Fox!! I knew I had read about something like this somewhere, and I was looking through my unorganized tutorials and I couldn''t find it.

Share this post


Link to post
Share on other sites
_Twiggie_    122
And possibly another good solution would be using a void *, which accepts any datatype (and furthermore you could cast them to an int, float, etc)


void DeAllocate(void *ptr)
{
delete ptr;
}


[edited by - _twiggie_ on January 24, 2004 7:48:26 AM]

Share this post


Link to post
Share on other sites