The declaration be :
When calling it, which of the following it a good practice ?...
template<class X,class Y> void foo(X,Y);
Both seems to be working for me....and I've seen some books sticking for the former
foo("bar",1); // no 1
...but the documentation(err..I've only looked into the one from cplusplus)...says(implicitly implies!!) that the implicit one works(or should work) for when X==Y
// *that follows after an example..so i,j,int are out of scope here..!
Since both i and j are of type int
, and the compiler can automatically find out that the template parameter can only be int. This implicit method produces exactly the same result: