【发布时间】:2018-04-22 23:07:02
【问题描述】:
我正在尝试从 dlib 项目中了解以下类型的类。
template<typename EXP>
class matrix_exp
{
public:
//typedef matrix<type, NR, NC, mem_manager_type, layout_type> matrix_type;
matrix_exp()
{
cout << "matrix_exp()" << endl;
cout << __PRETTY_FUNCTION__ << endl;
}
void foo()
{
cout << "matrix_exp" << endl;
}
};
template<typename T, long num_rows, long num_cols, typename mem_manager, typename layout>
class matrix: public matrix_exp<matrix<T, num_rows, num_cols, mem_manager, layout> >
{
public:
void foo()
{
cout << "matrix" << endl;
}
};
基类如何使用派生类作为模板?他们还使用了 typedef 矩阵 matrix_type;在 matrix_exp 中。有人可以澄清这是如何工作的吗?
【问题讨论】: