i have a `main' function that calls the `func' function
defined in `tem_aux.h'.
////////// the following is tem_main.cpp ///////////
#include "tem_aux.h"
int main(void) {
int a = 4;
func(a);
return 0;
}
////////// the following is tem_aux.h ///////////////
#ifndef _TEM_AUX_H_
#define _TEM_AUX_H_
template void func(T val);
#endif
////////// the following is tem_aux.cpp //////////////
#include "tem_aux.h"
template void func(T val) {
int i = 2;
}
when i compile usi
y****e 发帖数: 23939
2
把tem_aux.cpp中的东西挪到tem_aux.h中去,compiler needs to know the template
function at compile time