Method for implementing template functions in C language (continued):
/ * Define a macro to connect two identifiers: * /
#define make_name (classname, methodname) CALSSNAME ## __ ##MethodName
/ * Template source file: Template.c
* Macro that must be redefined: Theclass
* Other macros that need to be redefined (such as implementation of a search tree, need to compare elements or key-value macros)
*
* /
Int make_name (THECLASS, METHOD1) (int param1, int param2)
{
.
Return 0;
}
Int make_name (THECLASS, METHOD2) (Int param1, int param2)
{
.
Return 0;
}
Int make_name (THECLASS, METHOD3) (int param1, int param2)
{
.
Return 0;
}
... ..
/ * Quote This template file: SAMP1.C * /
#undef theclass
#define theclass class1
#include template.c
/ * end Samp1.c * /