In the following, shouldn't base class constructor be generated by the compiler based on derived class constructor argument type?
template <class T>
class foo
{
int a;
public:
foo(T a){}
// When I convert the constructor to a function template, it works fine.
// template <typename T> foo(T a){}
};
class bar : public foo<class T>
{
public:
bar(int a):foo(a){}
};
int main(void)
{
bar obj(10);
system("pause");
return 0;
}
error C2664: 'foo::foo(T)' : cannot convert parameter 1 from 'int' to 'T'
I understand the error, but why is that ?