그래서 체스 게임을 구현하려고했습니다.기본 생성자가없는 C++ 상속
error LNK2019: unresolved external symbol "public: __thiscall Bishop::~Bishop(void)" ([email protected]@[email protected]) referenced in function _main
그래서 여기
두 관련 클래스입니다 :
이Bishop.h (더 "Bishop.cpp"없다)
#pragma once
#ifndef BISHOP_H
#define BISHOP_H
#include "ChessPiece.h"
class Bishop : public ChessPiece
{
public:
Bishop(bool isWhite) : ChessPiece(isWhite) {
}
~Bishop(void);
// pure virtual functions
virtual CellLocation *listAvailableMoves(void) {
return 0;
}
virtual char getPieceType() {
return PIECE_TYPE_BISHOP;
}
};
#endif
나는 가장 일반적인 링크 오류가있어
ChessPiece.h은 "글롭에서
#ifndef CHESSPIECE_H
#define CHESSPIECE_H
#include "Globals.h"
// Abstract class for inheritence
class ChessPiece {
public:
// Constructor
ChessPiece(bool isWhite) : m_isWhite(isWhite) {
}
~ChessPiece(void);
// pure virtual functions
virtual CellLocation *listAvailableMoves(void) = 0;
virtual char getPieceType() = 0;
// ACCESSORS, MUTATORS
// isWhite member
bool isWhite(void) const{
return m_isWhite;
}
void setIsWhite(bool isWhite) {
m_isWhite = isWhite;
}
protected:
bool m_isWhite;
};
#endif
(아니오"ChessPiece.cpp "없음) als.h "에 대한 정의는 거의 없지만 내 기능과 관련이 없습니다. 그래서 나는 내가 무슨 짓을했는지 주요 단순히이었다
Bishop somePiece(true);
cout << sizeof(somePiece) << endl;
하지만 그것은 LNK2019 오류를했다.
이제는 솔루션이 양쪽 클래스 (어떤 이유로 작동하지 않음)에 기본 생성자를 추가해야한다는 것을 알고 있지만 기본 값으로 초기화하지 않기를 바랍니다. 따라서 나는이 클래스들 중 어느 것에 대해서도 디폴트 생성자를 원하지 않는다.
기본 생성자를 만들지 않고 제거하는 방법이 있습니까?
컴파일러는 당신이 정의되지 않았 음을 불평'~ 주교 (무효) '아직 – billz
링커는 소멸자 소멸자 구현에 대해 불평합니다. 생성자와 아무 관련이 없습니다! –
젠장 .... 그래, 고마워. –