I have a program like this:
class A {
int a[2][3];
public:
A(int b[2][3]): a(b) {};
};
int main() {
int b[2][3];
A myclass(b);
return 1;
}
The compiler says:
1.cpp: In constructor 'A::A(int (*)[3])':
1.cpp:5:22: error: incompatible types in assignment of 'int (*)[3]' to 'int [2][3]'
Why are they incompatible and how can I initialise array A::a by another array b?
int a[2][3]
is basically a constant pointer. One can't assign to constant pointer. You can only copy the full content. If you need to copy the pointer only you need to declare a pointer instead of array: