Suppose i need a five-dimensional array as class member and want to use it in different functions. For this puropose I use boost::multi_array e.g.:
class myClass {
typedef boost::multiarray<double, 5> fiveDim;
typedef fiveDim:: index index;
void init(){
fiveDim myArray(boost::extents[3][3][3][3][3]);
// I can use myArray in this scope
}
void printArray(){
// myArray not available here
}
Now, because of the function scope, i can clearly not use myArray in printArray(), but i also can't initialize the array directly in the class scope, outside a function (after the two typedefs.)
How do i define the array so that every class function is able to use it? The dimensions are known at compile time and always the same.
myArraymember variable ofmyClass. And after it themyArrayvariable will be available frommyClassmember functions. Check this code - coliru.stacked-crooked.com/a/520b01fd62e63ec0intclass member? What are the principal difficulties of replacingintwith the multi-array type?