我有这个代码:
int board[3][3]; // I am ommiting initialization code for board here so as not to clutter it.
typedef std::vector<std::pair<int [3][3], int> > History;
History hist = History();
const std::pair<int[3][3], int> p = std::make_pair(board, cell);
hist.push_back(p);
但是用 g++ 编译它给了我这个我无法理解的错误:
In file included from /usr/include/c++/4.7/bits/stl_algobase.h:65:0,
from /usr/include/c++/4.7/vector:61,
from performancesystem.h:29:
/usr/include/c++/4.7/bits/stl_pair.h: In instantiation of
‘std::pair<_T1, _T2>::pair(const std::pair<_U1, _U2>&) [with _U1 =
int (*)[3]; _U2 = int; _T1 = int [3][3]; _T2 = int]’:
Test.cpp:74:65: required from here
/usr/include/c++/4.7/bits/stl_pair.h:111:39: error: incompatible types in
assignment of ‘int (* const)[3]’ to ‘int [3][3]’
在理解 C++ 中指针和数组之间的区别时,我总是遇到这个问题。他们不应该是一样的吗?任何人都可以帮助我吗?