template<size_t N, size_t M>
class Matrix {
// ....
};
When you have this code
If you set default parameter
in the function, you don't have to write it separately when you call it
typedef Matrix<N,1> Vector<N>;
I want to use it like this.
But I can't compile it...
If you use the code below, it can be compiled It's a little different from what I want.
template <int N>
class Vector: public Matrix<N,1>
{ };
Help meㅜ<
c++ typedef template
C++11 supports alias declarations
.
typedef
has become more generalized, so you can write the code below in the template now!
template <size_t N>
using Vector = Matrix<N, 1>;
The type Vector<3> is equivalent to Matrix<3, 1>.
The closest thing to C++03 is
template <size_t N>
struct Vector
{
typedef Matrix<N, 1> type;
};
We're using it together.
Vector<3>::type
will have the same type as Matrix<3, 1>
.
© 2024 OneMinuteCode. All rights reserved.