2016-11-03 4 views
0

누구든지이 문제를 해결하는 방법에 대한 아이디어가 있는지 궁금합니다.C++에서 비 연결 헤더 파일 디버그

감사합니다. DataStructures.cpp에서

#ifndef DataStructures_hpp 
#define DataStructures_hpp 
void setup(struct Piece All[32]); 


#endif 

그리고이 코드 :

// 
// main.cpp 
// Chess 
// 
// Created by Akshar Ramkumar on 9/29/16. 
// Copyright © 2016 Akshar Ramkumar. All rights reserved. 
// 

#include <iostream> 
#include "DataStructures.hpp" 


int main() { 
    struct Piece { 
     int Type; 
     int x; 
     int y; 
     bool Captured; 
     bool Color; 
     char pictfile[7]; 
    }; 



    struct Piece All[32]; 
    setup(All); 
    return 0; 
} 

그리고 DataStructures.hpp이 코드 :

// 
// Classes.cpp 
// Chess 
// 
// Created by Akshar Ramkumar on 10/13/16. 
// Copyright © 2016 Akshar Ramkumar. All rights reserved. 
//Pawn = 0 
//Rook = 1 
//Knight = 2 
//Bishop = 3 
//King = 4 
//Queen = 5 

struct Piece { 
    int Type; 
    int x; 
    int y; 
    bool Captured; 
    bool Color; 
    char pictfile[7]; 
}; 

void setup(struct Piece All[32]){ 

    int TypeArray[32]={0,0,0,0,0,0,0,0,1,1,2,2,3,3,4,5,0,0,0,0,0,0,0,0,1,1,2,2,3,3,4,5}; 
    int xValues[32]={0,1,2,3,4,5,6,7,0,7,1,6,2,5,3,4,0,1,2,3,4,5,6,7,0,7,1,6,2,5,3,4}; 
    int yValues[32]={1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7}; 


    for (int i=0;i<32;i++){ 
     All[i].Type = TypeArray[i]; 
     All[i].y = yValues[i]; 
     All[i].x = xValues[i]; 
     All[i].Color = true; 
     All[i].Captured = false; 


     if (i>15){ 
      All[i].Color = false; 
     } 


    } 
} 

I MAIN.CPP이 코드와

다음과 같은 오류 메시지가 나타납니다 : main.cpp의 "Setup"호출과 일치하는 함수가 없습니다. 어떤 아이디어

+0

구조체 조각 모든 [32] 당신은 자신의 사용자 정의 타입의 객체를 만들 때 struct/class/union을 넣지 않는다. 전체 작품 [32]; 괜찮습니까 –

+0

코드의 어떤 줄에? –

+0

두 개의'Piece' 구조체를 정의했습니다. 한 곳으로 정의를 이동해야 DataStructures.hpp가 가장 좋습니다. 또 다른 한 가지는 위에서 언급 한 것처럼 struct 키워드를 사용할 필요가 없다는 것입니다. – woockashek

답변

1
코드의

기본 골격 :

// 
// main.cpp 
// Chess 
// 
// Created by Akshar Ramkumar on 9/29/16. 
// Copyright © 2016 Akshar Ramkumar. All rights reserved. 
// 

#include <iostream> 
namespace DataStructures { 
    struct Piece { 
     int Type; 
     int x; 
     int y; 
     bool Captured; 
     bool Color; 
     char pictfile[7]; 
    }; 

    void setup(Piece* pieces) { 
      //TODO 
    } 
}; 

int main() { 

    DataStructures::Piece All[32]; 
// Initialize All[32] here 
    DataStructures::setup(All); 
    return 0; 
} 
+0

1. 모든 것을 하나의 파일에 담는 것은 나쁜 습관입니다. 2. 둘 이상의 정적 메소드 중 하나만 포함하는 클래스를 작성하십시오. 대신 네임 스페이스를 사용할 수 있습니다. (또는 다른 파일에 별도의 요소가 계속) – woockashek

+0

코드의 기본 골격을 보여주고 싶습니다. 왜 모든 파일을 하나의 파일에 넣을까요? –

+0

지금은 더 좋지만 데이터 ** 구조의 메소드에 약간 불편합니다. ** 네임 스페이스;) – woockashek