I need to init a 2-dim array of forward_list after I read its sizes from input.
class Foo{
forward_list<int> * koo;
int A, B;
void boo(){
scanf("%d",&A);
scanf("%d",&B);
koo = new forward_list<int>[A][B];
koo[0][0] = 1;
}
};
Compiler:
cannot convert ‘std::forward_list<int> (*)[1]’ to ‘std::forward_list<int>*’ in assignment adjList = new forward_list<int>[A][A];
CLion IDE: Subscribed value is not an array (at koo[0])
I don't do much C++ so I don't quite know what's wrong. How can I do this right? I need to access all forward_list in O(1), and would, therefore, prefer arrays or generally something fast.
Btw: not sure if this is called dynamic initialization, let me know if I should change the title.
Thanks.