C++ 使用操作符::new和boost::multi_数组存储来自*的路径
我第一次尝试使用动态内存分配。我想为2维动态数组分配内存,以存储来自a*函数的路径。我认为该作业的数组是boost::multi_数组 问题我似乎能够分配内存,但我无法更改或访问任何元素C++ 使用操作符::new和boost::multi_数组存储来自*的路径,c++,C++,我第一次尝试使用动态内存分配。我想为2维动态数组分配内存,以存储来自a*函数的路径。我认为该作业的数组是boost::multi_数组 问题我似乎能够分配内存,但我无法更改或访问任何元素 #include <iostream> #include "boost/multi_array.hpp" typedef boost::multi_array<int, 2> array_type; int main() { array_type *A = new array
#include <iostream>
#include "boost/multi_array.hpp"
typedef boost::multi_array<int, 2> array_type;
int main()
{
array_type *A = new array_type;
A->resize( boost::extents[2][2] );
A[1][1] = 2;
std::cout << A[1][1] << std::endl;
delete A;
return 0;
}
#包括
#包括“boost/multi_array.hpp”
typedef boost::multi_array_type;
int main()
{
数组类型*A=新数组类型;
A->resize(boost::extensts[2][2]);
A[1][1]=2;
std::cout下面的解决方案适合我。很抱歉之前的混淆
#include <iostream>
#include "boost/multi_array.hpp"
typedef boost::multi_array<int, 2> array_type;
int main()
{
array_type *A = new array_type(boost::extents[2][2]);
(*A)[1][1] = 2;
std::cout << (*A)[1][1] << std::endl;
delete A;
return 0;
}
#包括
#包括“boost/multi_array.hpp”
typedef boost::multi_array_type;
int main()
{
数组_-type*A=新的数组_-type(boost::extensts[2][2]);
(*A)[1][1]=2;
标准::cout
#include <iostream>
#include "boost/multi_array.hpp"
typedef boost::multi_array<int, 2> array_type;
int main()
{
array_type *A = new array_type(boost::extents[2][2]);
(*A)[1][1] = 2;
std::cout << (*A)[1][1] << std::endl;
delete A;
return 0;
}