I am an very beginner and try this in codeblock,windowXP.
main.cpp as followed
1 2 3 4 5 6 7 8 9 10 11
class printtt;
usingnamespace std;
typedefunsignedint type_num;
int main()
{
type_num asdf[3]; //if changed to "int asdf[3];", it has no error why?
asdf[0]=4;
printtt::nothing(asdf,4); //<-- error here \testOnly\main.cpp|13|undefined
//reference to `void printtt::nothing<unsigned int>(unsigned int*, int)
return 0;
}
I don't know why int works, but generally, definition of a template function must be 'visible' when the function is called. This means you have to put it inside a header.
Thank hamsterman, I get it !!!
I didn't understand what hamsterman said enough and read my book again, it said that a function in class that use template must 1.inline function or 2. in the "same" file of the function declaration only. It's just what hamsterman had already said.
printtt.h