template<class T>
class test
{
public:
test()
{
}
test(T& e)
{
}
};
int main()
{
test<double> d(4.3);
return 0;
}
Compiled using g++ 4.4.1 with the following errors:
g++ test.cpp -Wall -o test.exe
test.cpp: In function 'int main()':
test.cpp:18: error: no matching function for call to 'test<double>::test(double)
'
test.cpp:9: note: candidates are: test<T>::test(T&) [with T = double]
test.cpp:5: note: test<T>::test() [with T = double]
test.cpp:3: note: test<double>::test(const test<double>&)
make: *** [test.exe] Error 1
However, this works:
double a=1.1;
test<double> d(a);
Why is this happing? Is it possible that g++ cannot implicitly convert literal expression 1.1 to double? Thanks.