template <class T1, ...>
typename
f(1, 1.0)
does not matchtemplate <class t1,class t2>f(t1 a1, t2 a2) { . . . }
template <class t> inline t max(t v1, t v2) { return v1 > v2 ? v1 : v2; } void fint(int x, int y) { int m = max(x, y); } void fdbl(double x, double y) { double m = max(x, y); } void fstr(std::string & x, std::string & y) { std::string m = max(x, y); }
template<int size> void t(int i) { int iarray[size]; iarray[i] = i; } int main() { t<10>(3); }
template <class t> t * oops(int i) { i++; return new t; } void f(void) { int * ip = oops(1); }
void f(void) { int * ip = oops(1); }
template <class t> void oops(t i, t j) { // whatever } void f(void) { int i = 3; unsigned j = 4; oops(i, j) }
const
s are another source of problems, particularly in the stl
This page last modified on 30 October 2001.