a friend , beginners c++ , qt. working on qt project (the helicopter game) , when sent me code had on computer, ran without errors, gave "expected type-specifier" error on line set pointer equal new instance our "game" constructor. there wrong code or have computer?
this our error appears in main function:
#include <qapplication> #include <qgraphicsitem> #include <qgraphicspixmapitem> #include <qgraphicsview> #include <qgraphicsscene> //including splash screen #include <qsplashscreen> #include <qtimer> //our header files #include "player.h" #include "game.h" game * heli_game; int main(int argc, char *argv[]) { qapplication a(argc, argv); qsplashscreen * splash = new qsplashscreen; splash->setpixmap(qpixmap(":/images/splash.png")); splash->show(); game * heli_game; heli_game = new game::game(); //error here: "expected type-specifier" qtimer::singleshot(2500, splash, slot(close())); return a.exec(); }
and here's our game header file constructor defined:
#ifndef game #define game #include <qgraphicsview> #include <qwidget> #include <qgraphicsscene> #include "player.h" #include "score.h" //#include "game_over.h" class game: public qgraphicsview{ q_object public: //constructors game(qwidget* parent=null); //public attributes qgraphicsscene * scene; player * copter; score * score; // game_over * game_over; }; #endif // game
new game::game();
^ make sense if game
class in namespace called game
. since isn't, compiler has no way of knowing type you're referring to.
what meant this:
new game();
i should point out heli_game
declared twice in main file.