C ++模板typedef - C++ template typedef

语言: CN / TW / HK

问题:

I have a class 我有一堂课

template<size_t N, size_t M>
class Matrix {
    // ....
};

I want to make a typedef which creates a Vector (column vector) which is equivalent to a Matrix with sizes N and 1. Something like that: 我想做一个typedef来创建一个Vector (列向量),它等效于大小为N和1的Matrix

typedef Matrix<N,1> Vector<N>;

Which produces compile error. 产生编译错误。 The following creates something similar, but not exactly what I want: 以下创建类似的东西,但不完全是我想要的东西:

template <size_t N>
class Vector: public Matrix<N,1>
{ };

Is there a solution or a not too expensive workaround / best-practice for it? 是否有解决方案或不太昂贵的解决方法/最佳实践?


解决方案:

参考一: http://stackoom.com/question/Bj71
参考二: C++ template typedef
「其他文章」