我在 myclass.hpp 中有一个类模板:
template<class T, class P>
class myclass
{
....
};
Run Code Online (Sandbox Code Playgroud)
在我的 main.cc 中,我创建了该类的一个对象:
myclass<int, double> mc;
otherfunc<myclass>(mc);
Run Code Online (Sandbox Code Playgroud)
在其他一些头文件header1.hpp中:
template<class MyClass>
void otherfunc(MyClass const &mc)
{
/* Access through 'mc' the underlying template parameters T and P*/
}
Run Code Online (Sandbox Code Playgroud)
如何访问 header1.hpp 中的模板参数 T 和 P?