以下代码给出编译错误:
template <typename T>
class Base
{
public:
void bar(){};
};
template <typename T>
class Derived : public Base<T>
{
public:
void foo() { bar(); } //Error
};
int main()
{
Derived *b = new Derived;
b->foo();
}
错误
Line 12: error: there are no arguments to 'bar' that depend on a template parameter, so a declaration of 'bar' must be available
为什么会出现这个错误?