Hello,
Let's not refer to ourselve but to compiler!
Try this:
__________________________
File 1: Main.cpp
__________________________
#include
#include "ADD2.h"
int main (int argc, char * const argv[]) {
int a=3;
float b=3.3;
printf("\na=%d \t ADD2(a)=%d",a,ADD2(a));
printf("\nb=%f \t ADD2(b)=%f",b,ADD2(b));
}
__________________________
File 2: ADD2.h
__________________________
#ifndef ADD2_H
#define ADD2_H
template
T ADD2(T a);
template
T ADD2(T a)
{
a=a+(T)2;
}
#endif
__________________________
This just works fine but if you remove function body then like this:
Modified File 2: ADD2.h
__________________________
#ifndef ADD2_H
#define ADD2_H
template
T ADD2(T a);
#endif
__________________________
ADDED File 3: ADD2.cpp
__________________________
#include "ADD2.H"
template
T ADD2(T a)
{
a=a+(T)2;
}
__________________________
This Time again it will be compiled but a run time error like this can happen:
ZeroLink: unknown symbol '__Z4ADD2IiET_S0_'
It seems clear that we must define all the template in *.hpp??