I am not very good with c++ and was wondering why an error happens with arrays inside of arrays, but works fine with a normal array (and how to fix it possibly).
Heres the code (just trying to store an array inside a class upon constructing it):
class foo {
int* stored;
public:
foo(int* ptr) {
stored = ptr;
}
};
int main() {
int arr[][2] = {{1,4},{5,7},{2,5}};
foo obj(arr);
}
When the array is something like int arr[] = {1,2,3}
it works without errors, but the normal code gives me this error:
error: no matching function for call to 'foo::foo(int [3][2])'
I searched around for a while, but I don't really know what to search for in the first place, which is why I am asking here (but I feel it has something to do with pointers). Thanks for any help.