相关疑难解决方法(0)

C++矩阵类

在C中,如果我想创建一个矩阵结构,我会使用:

struct matrix {
  int col, row;
  double data[1]; // I want the matrix entries stored
                  // right after this struct
}
Run Code Online (Sandbox Code Playgroud)

然后我可以分配它

matrix* allocate_matrix(int row, int col) {
  matrix* m = malloc(sizeof(matrix) + sizeof(double) * (row * col - 1));
  m->row = row; m->col = col;
  return m;
}
Run Code Online (Sandbox Code Playgroud)

现在我在C++中做等效吗?

编辑:

我想知道在C++中实现矩阵类的方法.

c++ matrix

25
推荐指数
5
解决办法
10万
查看次数

标签 统计

c++ ×1

matrix ×1