gpt4 book ai didi

c++ - MSVS 意外类错误 : Didn't forget the semicolon though

转载 作者:太空宇宙 更新时间:2023-11-04 15:51:06 26 4
gpt4 key购买 nike

在我下面的代码中,我得到了这个编译器错误 error C2236: unexpected 'class' 'Pawn'。您是不是忘记了一个“;”? 但是正如您清楚地看到的那样,我没有漏掉一个分号……是吗?我曾经认为这是由于循环依赖性导致的问题,但我删除了 vector 旁边的任何包含。这个类也应该继承 self 的 Piece 类,但即使在删除它之后我仍然会遇到错误。

#ifndef CHESS_PAWN_H
#define CHESS_PAWN_H

#include <vector>

class Pawn {
private:
bool _hasMoved;

public:
Pawn(int x, int y);
~Pawn();

std::vector<int> availMoves();
};

#endif

关于我在这里做错了什么有什么建议吗?

最佳答案

推断,您的 chess.cpp 文件可能如下所示:

#include "piece.h"
#include "pawn.h"
//etc..

缺少的分号位于 piece.h 中。标准预处理器损失。

关于c++ - MSVS 意外类错误 : Didn't forget the semicolon though,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8113403/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com