I have the following struct which I wanted to initialize
struct Box{
int *dimval;
int no;
int dim;
Box(dim){
this->dim = dim;
dimval = new int[dim]
}
}
now in my main function. I wanted to initialize an array of Box struct, but this is problematic with my implementation.
int main(){
Box *boxes;
int num_box, dim;
cin>>num_box>>dim;
boxes = new Box[num_box](dim);// I know this is devil here.
}
I want to have a dynamic array containing num_box Box items, each being initialized with a dynamic array of dim long. How can I do that?