초기화하는 크기는 유형과 아무 관계가 없습니다. 따라서 :
// this makes things easier!
typedef boost::numeric::ublas::matrix<double> matrix_type;
// this is the type (no initialization)
matrix_type arrayM[arraySize];
문제는 배열을 초기화 할 때 발생합니다.
TheClass::TheClass()
{
std::fill(arrayM, arrayM + arraySize, matrix_type(1, 3));
}
당신이 부스트를 사용하고 있기 때문에이 boost::array
을 사용하는 것이 좋습니다 : 당신은이 작업을 수행 할 수 없습니다 모든
TheClass::TheClass() :
arrayM(1, 3) // nope
{}
대신에, 당신이 그 (것)들을 기본-구조를 수 있도록해야하고 그들에게 크기를 조정 왜냐하면 더 멋진 구문을 제공하기 때문입니다.
typedef boost::numeric::ublas::matrix<double> matrix_type;
typedef boost::array<matrix_type, arraySize> matrix_array;
matrix_array arrayM; // ah
TheClass::TheClass()
{
arrayM.assign(matrix_type(1, 3));
}
와우. 날 2 초 전에 똑같은 것을 올렸다. 나는 감동. 그것을 설명하는 좋은 링크가 있고 내 대답을 삭제하겠습니다 : http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.5 –