Today I have decided to program like a pro and implement a "One function to do everything" class that acts as an entry point into any program I will ever make again. I call it, the 'Jerk API'. How does this work? Well, let me tell you.
First and foremost, let us look at the greatest operator overload to exist:
operator()
Why? Why is this awesome? I will continue after we look at the greatest return type ever created:
void*
"Whoa!" You may be saying. I agree, it is "Whoa" worthy. The best return type is now combined with the ultimate operator to exist:
void* operator()
Do you see where this is goin? If so, you should keep on reading. Because the ultimate function that should only ever be implemented in every API, SDK, software package, library, so on and so forth is as follows:
void* operator(...);
Yes, the ultimate function. It is the one ring of programming, the Filet Mignon, the Mt. Everest, just simply the best!
For those of you who are not familiar with this sort of epic programming, let us look more closed at the void* return type. Firstly, what is void? It means nothing, or no type. How awesome is that! We don't need to worry about what we return because it doesn't care. Making it a pointer allows us to actually return a pointer to something that somebody else has to worry about casting to the right object. We can return whatever we want, when we want, and however we choose so.
Now let us take a look at the best parameter argument in existence as well, the vararg (...). This allows us to accept any number of arguments without telling the mewling babe of a programmer who uses our library/API/etc. the types of the arguments or even a description. A true interface that only the pros can handle.
With that being said, let me give a great example of all the fun we can have! I even included unions for this example (probably just as awesome of a argument as the varargs). (I would click it to see all of the glory)
Well, isn't that just great? I concur. Anyways, if you want to be a pro programmer, always remember, your classes need only one method.
void* operator()(...);
ENJOY!