我有一个包含std :: arrays的双端队列。包含数组的结构
我想将它转换为包含结构体的deque。 我所做的结构是这样的:
struct New_Array {
array<array<int,4>,4> tablee;
int h;
} Jim;
而且我有一个名为访问双端队列:
deque<New_Array> visited;
我有一个这样的函数打印名为PrintBoard数组。
void PrintBoard(New_Array tt) {
using namespace std;
for (int iRow = 0; iRow < 4; ++iRow) {
for (int iCol = 0; iCol < 4; ++iCol) {
cout << tt.tablee[iRow][iCol];
cout << " ";//This space helps so the numbers can be visable
//to the user
}
cout << endl;
}
}
当我写PrintBoard(visited.front());
它给了我error C2664: 'PrintBoard cannot convert parameter 1 from 'New_Array' to std:tr1::array<_Ty,Size>'.
问题是什么?我从未将表格用作一维。
编辑:
#include <deque>
#include <vector>
#include <array>
using namespace std;
struct New_Array {
array<array<int,4>,4> tablee;
int h;
}str_test,Jim;
deque<New_Array> visited;
void dfs()
{
PrintBoard(visited.front());//****the error is in this line****
}
void PrintBoard(New_Array tt) {
using namespace std;
for (int iRow = 0; iRow < 4; ++iRow) {
for (int iCol = 0; iCol < 4; ++iCol) {
cout << tt.tablee[iRow][iCol];
cout << " ";//This space helps so the numbers can be visable
//to the user
}
cout << endl;
}
}
int main()
{
dfs();
char test_char;
cin>> test_char;
return EXIT_SUCCESS;
}
你可以将它形成一个我们可以尝试编译的代码块(即[SSCCE](http://sscce.org))吗?我把上面的代码放到一个文件中,并写了一个main(),它为我编译w/gcc – je4d 2012-04-03 00:11:54
错误来自哪里,哪里是你的示例? – ssube 2012-04-03 00:14:15
@ je4d查看我的编辑 – 2012-04-03 00:24:59