2012-04-03 2 views
0

나는 std :: arrays를 포함하는 deque를 가지고있다.배열을 포함하는 구조체

struct가 들어있는 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>'.

을 준다? 테이블을 일차원 적으로 사용하지 않았습니다.

편집 :

#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()을 작성하면 g/w를 사용하여 컴파일됩니다. – je4d

+0

샘플에서 오류가 발생한 행은 무엇입니까? – ssube

+0

@ je4d 편집 내용보기 –

답변

1

귀하의 예제에서 PrintBoard의 선언이 dfs()에 사용되는 경우 이후이다. 이것이 당신의 코드가 구조화 된 방법이라면, 배열을 인자로 취하는 또 다른 PrintBoard 선언을 먼저 가질 수 있습니다. 당신이 거기에 당신의 포함에 의해 끌어 들여지고있는 오래된 선언을 가지고있을 가능성이 있습니다.

사용하기 전에 PrintBoard의 선언을 이동해보십시오.

+0

문제는 PrintBoard를'PrintBoard void (array , 4>)'와 같이 선언했기 때문입니다. 올바른 것은이'void PrintBoard (New_Array tt)'입니다. –

관련 문제