Hello everyone,
Here is the code and related compile error information. I am using Visual Studio 2008. Not sure whether you can compile using your compiler? Why Visual Studio 2008 can not deduce template parameter type?
thanks in advance,
George
Here is the code and related compile error information. I am using Visual Studio 2008. Not sure whether you can compile using your compiler? Why Visual Studio 2008 can not deduce template parameter type?
Code:
#include <iostream>
using namespace std;
template <class T> void f(int a) {g (a);}
void g(int a)
{
cout << a << endl;
}
int main()
{
f (100); // can not compile, error C2783: 'void f(int)' : could not deduce template argument for 'T'
// f<int> (100) can compile
return 0;
}
thanks in advance,
George