#include <iostream>
namespace oo{
class A{
public:
template<typename T>
static T get_value(){return static_cast<T>(55);}
};
template <typename T=A>
class B{
public:
static double f(){return T::get_value<double>();}
};
}
int main(int argc, char *argv[])
{
using std::cout;
using std::endl;
cout << oo::B<oo::A>::f() << endl;
return 0;
}
Considering the example up here, it compiles with an error "type name is not allowed" which refers to "double" and arguments in "get_value()".
Someone has righted this wrong by rewriting the function f() as followed:
static double f(){return T::template get_value<double>(); }
Yet, I do not quite understand the use of "template" here. Could anyone explain that to me, please?
Thanks in advance for your comments.