【发布时间】:2016-04-06 00:42:54
【问题描述】:
假设我们有
template<typename T>
class Base
{
...
protected:
template<typename U>
void compute(U x);
...
};
现在我想从派生类调用这个方法。对于非模板成员函数,我通常会使用using ... 声明或使用this->... 访问成员。但是,不清楚如何访问模板成员:
template<typename T>
class Derived : public Base<T>
{
// what's the correct syntax for
// using ... template ... Base<T>::compute<U> ... ?
...
void computeFloat()
{
float x = ...;
compute<float>(x);
}
void computeDouble()
{
double x = ...;
compute<double>(x);
}
...
};
【问题讨论】: