Blow your mind

Take a careful look at this:

[source:c]

include

class Gadget { public: void sayHello() const { std::cout << “Gadget!” << std::endl; } };

class Widget { public: void sayHello() const { std::cout << “Widget!” << std::endl; } };

template class OpNewCreator { public: T* create() { std::cout << “Using ‘new’: “; return new T; } };

template class MallocCreator { public: T* create() { std::cout << “Using ‘malloc’: “; void* buf = std::malloc(sizeof(T)); if (!buf) return 0; return new(buf) T; } };

template