65,208
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include "boost/shared_array.hpp"
int main(int argc, char** argv)
{
int n = 2, m = 3;
boost::shared_array< boost::shared_array<int> > matrix(new boost::shared_array<int>[n]);
for (int row = 0; row < n; ++row)
{
matrix[row].reset(new int[m]);
for (int col = 0; col < m; ++col)
{
matrix[row][col] = row + col;
}
}
for (int row = 0; row < n; ++row)
{
for (int col = 0; col < m; ++col)
{
std::cout << "(" << row << "," << col <<"):" << matrix[row][col] << std::endl;
}
}
return 0;
}
(0,0):0
(0,1):1
(0,2):2
(1,0):1
(1,1):2
(1,2):3