You want to offer a working definition of "polymorphism", then?
Macros certainly allow you to write code that's applied to differently typed arguments.
Macros certainly allow you to write code that's applied to differently typed arguments.
FOO.hxx:
TYPE FOO_TEMPLATE () {
TYPE foo;
/*...*/
return foo;
}Foo.h:
#DEFINE FOO_TEMPLATE foo_int
#DEFINE TYPE int
#include "Foo.hxx"
#DEFINE FOO_TEMPLATE foo_float
#DEFINE TYPE float
#include "Foo.hxx"
It's a kind of weird and ugly macro trick, bug it can be useful in C when one's need polymorphism and performance (and cannot use C++ at all, which is a far better solution).
[Edit:] I realize now it's not polymorphism like said in the article, because the caller had to tell explicitly which foo_xxx to call. But it did provide "polymorphic" code in Foo.hxx (so only one implementation, no repetition). That said, a cast is also explicit.