// hello.h
template<typename T>
bool comp( T first, T second )
{
return first < second;
}
// hello.cpp
template bool comp(int, int); // would ONLY allow comp to access int
// main.cpp
std::cout << std::boolalpha << comp(10, 12) << std::endl; // fine
std::cout << std::boolalpha << comp(2.2, 3.3) << std::endl; // fine why!
Question 1> It seems that I cannot put the implementation code for comp
in hello.cpp
. Is that true?
Question 2> I try to limit the input parameters of comp
to integer ONLY. why the second line in the main.cpp
still compiles?
Thank you