can i create my own array type?

i need create a especific array type: Matrix4X4. but is like:
float ProjectionMatrix[4][4];
can i create a type, using typedef or something, for what i need?
something like:
1
2
3
 typedef array[4][4] Matrix4X4;
Matrix4X4 Projection;
Projection[0][0] = 100;

ok.. that line is wrong but is for help what i need.
Last edited on
using Matrix4x4 = float[4][4];
Or
typedef float Matrix4x4[4][4];
A more generic approach:
1
2
3
4
5
6
7
8
9
10
11
template<class T, size_t Rows, size_t Cols>
class Matrix
{
public:
  // TO DO
  // implement logic, i.e. setter, getter, print ...
private:
  T data[Rows][Cols];  
};

Matrix<float, 4, 4> matrix4x4; 
There's also Eigen, which already has a bunch of matrix types and linear algebra operations implemented.
The 'typedef' and 'using' do not create "new type"; they define an alias -- an another, more convenient name -- for the existing type.

I'd guess that the four by four here is about 3D graphics transformations. There definitely are libraries/frameworks for that too.
Topic archived. No new replies allowed.