누구든지이 문제를 해결하는 방법에 대한 아이디어가 있는지 궁금합니다.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"호출과 일치하는 함수가 없습니다. 어떤 아이디어
구조체 조각 모든 [32] 당신은 자신의 사용자 정의 타입의 객체를 만들 때 struct/class/union을 넣지 않는다. 전체 작품 [32]; 괜찮습니까 –
코드의 어떤 줄에? –
두 개의'Piece' 구조체를 정의했습니다. 한 곳으로 정의를 이동해야 DataStructures.hpp가 가장 좋습니다. 또 다른 한 가지는 위에서 언급 한 것처럼 struct 키워드를 사용할 필요가 없다는 것입니다. – woockashek