2012-04-03 14 views
0

私はstd :: arraysを含む両端キューを持っています。配列を含む構造体

構造体を含むdequeに変換したいです。 私が作った構造体は、このようなものです:

struct New_Array { 
array<array<int,4>,4> tablee; 
int h; 
} Jim; 

そして私が訪問した名前が付けられていデック:

deque<New_Array> visited; 

私はそのような機能がPrintBoardという名前の配列を印刷しています。私はPrintBoard(visited.front());を書くとき

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; 
     } 

} 

それが問題である何私にerror C2664: 'PrintBoard cannot convert parameter 1 from 'New_Array' to std:tr1::array<_Ty,Size>'.

を与えますか?私はテーブルを一次元として使ったことはありません。

EDIT:

#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; 
    } 
+2

これをコンパイルできるコードブロック([SSCCE](http://sscce.org))にまとめることはできますか?上記のコードをファイルに入れてmain()を書いて、gccで私のためにコンパイルします – je4d

+0

どのような行がエラーですか、そしてあなたのサンプルはどこですか? – ssube

+0

@ je4d私の編集を参照 –

答えて

1

あなたの例ではPrintBoardの宣言は、それがdfs()で使用されているところの後です。これがあなたのコードが構造化されている方法であれば、配列を引数として受け取る別のPrintBoard宣言を先に持つかもしれません。あなたのインクルードによって引っ張られているどこかに古い宣言がある可能性があります。

PrintBoardの宣言を使用する前に移動してみてください。

+0

問題は、PrintBoardを 'void PrintBoard(array ,4> tt)'のように宣言したことでした。正しいものはこの 'void PrintBoard(New_Array tt)'です。 –