Most complier fail to implement the compliing mechnisam of function template-separation model, include g++,v s2008. Follow is my test code.
in "separation_model.h"
#
if
!
defined(SEPARATION_MODEL)
#define SEPARATION_MODEL
template < class T >
T _max(T pf,T ps);
#endif
#define SEPARATION_MODEL
template < class T >
T _max(T pf,T ps);
#endif
in "separation_model.cpp"
#include
"
separation_model
"
export template < class T >
T _max(T pf, T ps) ... {
if (pf > ps) return pf;
else return ps;
}
export template < class T >
T _max(T pf, T ps) ... {
if (pf > ps) return pf;
else return ps;
}
in test code "separetion_test.cpp"
#include
"
separation_model.h
"
#include < iostream >
using namespace std;
int main( int argc, char * argv[])
... {
cout << _max(10, 20) << endl;
system("pause");
return 0;
}
#include < iostream >
using namespace std;
int main( int argc, char * argv[])
... {
cout << _max(10, 20) << endl;
system("pause");
return 0;
}