【发布时间】:2014-02-19 15:02:41
【问题描述】:
我有一个这样的程序:
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;
}
编译器说:
1.cpp: In constructor 'A::A(int (*)[3])':
1.cpp:5:22: error: incompatible types in assignment of 'int (*)[3]' to 'int [2][3]'
为什么它们不兼容?如何通过另一个数组 b 初始化数组 A::a?
【问题讨论】:
标签: c++ arrays assignment-operator data-members