Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取头文件中的声明错误 我在QT创建者中开发了一个使用C++的突破游戏。我得到一个错误,说“游戏尚未宣布”。我已经用游戏声明了。错误在头文件中。我想不出问题出在哪里。求求你,我们将非常感谢你的帮助 #ifndef BALL_H #define BALL_H #include<QCloseEvent> #include <QGraphicsRectItem> #include "game.h" //i have declared it here. class Ball: public QObject, public QGraphicsRectItem{ Q_OBJECT public: // constructors Ball(QGraphicsItem* parent=NULL); QTimer *runTimer; // public methods double getCenterX(); public slots: // public slots void move(); void start_timer(); void stop_timer(); void call_game_fuction(Game *gm); //here i am getting the error(Game) private: // private attributes double xVelocity; double yVelocity; int counter = 0; // private methods void resetState(); bool reverseVelocityIfOutOfBounds(); void handlePaddleCollision(); void handleBlockCollision(); }; #endif // BALL_H_C++_Qt - Fatal编程技术网

获取头文件中的声明错误 我在QT创建者中开发了一个使用C++的突破游戏。我得到一个错误,说“游戏尚未宣布”。我已经用游戏声明了。错误在头文件中。我想不出问题出在哪里。求求你,我们将非常感谢你的帮助 #ifndef BALL_H #define BALL_H #include<QCloseEvent> #include <QGraphicsRectItem> #include "game.h" //i have declared it here. class Ball: public QObject, public QGraphicsRectItem{ Q_OBJECT public: // constructors Ball(QGraphicsItem* parent=NULL); QTimer *runTimer; // public methods double getCenterX(); public slots: // public slots void move(); void start_timer(); void stop_timer(); void call_game_fuction(Game *gm); //here i am getting the error(Game) private: // private attributes double xVelocity; double yVelocity; int counter = 0; // private methods void resetState(); bool reverseVelocityIfOutOfBounds(); void handlePaddleCollision(); void handleBlockCollision(); }; #endif // BALL_H

获取头文件中的声明错误 我在QT创建者中开发了一个使用C++的突破游戏。我得到一个错误,说“游戏尚未宣布”。我已经用游戏声明了。错误在头文件中。我想不出问题出在哪里。求求你,我们将非常感谢你的帮助 #ifndef BALL_H #define BALL_H #include<QCloseEvent> #include <QGraphicsRectItem> #include "game.h" //i have declared it here. class Ball: public QObject, public QGraphicsRectItem{ Q_OBJECT public: // constructors Ball(QGraphicsItem* parent=NULL); QTimer *runTimer; // public methods double getCenterX(); public slots: // public slots void move(); void start_timer(); void stop_timer(); void call_game_fuction(Game *gm); //here i am getting the error(Game) private: // private attributes double xVelocity; double yVelocity; int counter = 0; // private methods void resetState(); bool reverseVelocityIfOutOfBounds(); void handlePaddleCollision(); void handleBlockCollision(); }; #endif // BALL_H,c++,qt,C++,Qt,先生,这是我的游戏档案 #ifndef GAME_H #define GAME_H #include <QGraphicsView> #include <QGraphicsScene> #include "Ball.h" #include "Paddle.h" #include "Block.h" #include<QPushButton> class Game:public QGraphicsView{ Q_OBJECT public: // con

先生,这是我的游戏档案

#ifndef GAME_H
#define GAME_H

#include <QGraphicsView>
#include <QGraphicsScene>
#include "Ball.h"
#include "Paddle.h"
#include "Block.h"
#include<QPushButton>

class Game:public QGraphicsView{

Q_OBJECT

public:
// constructors
Game(QWidget* parent=0);
QPushButton *button;
QPushButton *button1;




// public methods




void start();
void createBlockCol(double x);
void creatBlockGrid();
void set_background();
void background_Gamewon();
void set_buttons();

QGraphicsScene* scene2;




// public attributes
QGraphicsScene* scene;
QGraphicsView* view;


private slots:
void startgame();
void stopgame();





private:
bool gameOver;
Ball *ball;
Paddle *pad;
Block *bl;


};

#endif // GAME_H
\ifndef游戏
#定义游戏
#包括
#包括
#包括“Ball.h”
#包括“桨.h”
#包括“Block.h”
#包括
课堂游戏:公共QGraphicsView{
Q_对象
公众:
//建设者
游戏(QWidget*parent=0);
QPushButton*按钮;
QPushButton*按钮1;
//公共方法
void start();
void createBlockCol(双x);
void创建块网格();
void set_background();
无效背景_Gamewon();
无效设置按钮();
qgraphicscene*场景2;
//公共属性
qgraphicscene*场景;
QGraphicsView*视图;
专用插槽:
void startgame();
无效停止游戏();
私人:
布尔·加莫弗;
球*球;
桨*垫;
区块*bl;
};
#endif//GAME_H

您具有循环依赖关系。球。h包括游戏。h和游戏。h包括球。h。这对于编译器来说是不可能解决的情况,因为两者都不能包含在另一个之前

看来game.h不需要包含“Ball.h”。相反,请使用转发声明:

class Ball;

这应该足以编译game.h.

您有一个循环依赖项。球。h包括游戏。h和游戏。h包括球。h。这对于编译器来说是不可能解决的情况,因为两者都不能包含在另一个之前

看来game.h不需要包含“Ball.h”。相反,请使用转发声明:

class Ball;

这应该足够编译game.h.

了,如果编译器说它还没有被声明,那么在关于(看不见的)头的评论中声称“我在这里声明了它”是没有帮助的。你认为你已经声明了,编译器告诉你没有。给我们看标题。甚至更好的是,修剪头文件和源文件,直到它们所做的只是复制错误(即a),然后发布该错误。(除非你在修整过程中发现了问题,这是可能的)。引用弗兰SouthoIsand Riuux——考虑提供一个。您的示例需要特定的文件,我们无法猜测它们包含什么。如果我们可以自己尝试您的代码,那么识别问题就会容易得多。使用重要的名字也可以帮助理解和解释你的代码;主席先生,这没有帮助,正如你所看到的,我已经提供了,主席先生,如果编译器说它还没有被声明,在关于(看不见的)头的评论中声称“我在这里声明了它”是没有帮助的。你认为你已经声明了,编译器告诉你没有。给我们看标题。甚至更好的是,修剪头文件和源文件,直到它们所做的只是复制错误(即a),然后发布该错误。(除非你在修整过程中发现了问题,这是可能的)。引用弗兰SouthoIsand Riuux——考虑提供一个。您的示例需要特定的文件,我们无法猜测它们包含什么。如果我们可以自己尝试您的代码,那么识别问题就会容易得多。使用重要的名字也可以帮助理解和解释你的代码;先生,那没用,正如你所看到的,我已经提供了,先生,