Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 397729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:40:43+00:00 2026-05-12T16:40:43+00:00

I have a header file like so: #pragma once #include gamestate.h #include ExitListener.h class

  • 0

I have a header file like so:

#pragma once
#include "gamestate.h"
#include "ExitListener.h"

class InitialGameState : public GameState
{
public:
  InitialGameState(Ogre::Camera *cam, Ogre::SceneManager *sceneMgr, OIS::Keyboard      *keyboard, OIS::Mouse *mouse, Ogre::Root *root);
  ~InitialGameState(void);
  virtual bool update(Ogre::Real time);
  virtual void pause(void);
  virtual void start(void);
  void keyPressed(const OIS::KeyEvent &e);
  void keyReleased(const OIS::KeyEvent &e);
//private:
ExitListener *mFrameListener;
};

The problem with this is that I get the following errors from VC 8:

InitialGameState.h(16) : error C2143: syntax error : missing ';' before '*'  
InitialGameState.h(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int  
InitialGameState.h(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int  

(they all refer to the last line)

I have a class ExitListener.h which is why I don’t get the errors

Edit: ExitListener.h:

#pragma once
#include <Ogre.h>
#include <OIS/OIS.h>
#include <CEGUI/CEGUI.h>
#include <OgreCEGUIRenderer.h>
#include "Thing.h"
#include "InitialGameState.h"

using namespace Ogre;
class ExitListener : public FrameListener, public OIS::KeyListener, public     OIS::MouseListener
{
public:
ExitListener(OIS::Keyboard *keyboard, OIS::Mouse *mouse, Camera *cam, std::vector<Thing*> &vec): 
  mKeyboard(keyboard), r(0.09), mContinue(true), mRunningAnimation(false),
mMouse(mouse), mYaw(0), mPitch(0), things(vec), mCamera(cam), mWDown(false), mSDown(false), mADown(false),
mDDown(false)
{
  things = vec;
  mKeyboard->setEventCallback(this);
  mMouse->setEventCallback(this);
}
bool frameStarted(const FrameEvent& evt);   
bool keyPressed(const OIS::KeyEvent &e);
bool keyReleased(const OIS::KeyEvent &e);
bool mouseMoved(const OIS::MouseEvent &e);
bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id);
bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id);

void setOwner(GameState *g);

private:
  AnimationState *mSwim;
  Radian r;
  Radian mYaw;
  Radian mPitch;
  OIS::Keyboard *mKeyboard;
  OIS::Mouse *mMouse;
  Camera *mCamera;
  bool mContinue;
  bool mRunningAnimation;
  std::vector<Thing*> &things;
  bool mWDown;
  bool mADown;
  bool mDDown;
  bool mSDown;
  GameState *mOwner;
};

Edit 2:

It turned out that the problem could be solved by a forward declaration and then including the other header directly in my .cpp file.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:40:44+00:00Added an answer on May 12, 2026 at 4:40 pm

    My guess is that ExitListener.h is including InitialGameState.h header file either directly or indirectly. So there is a circular dependency between the header file and compiler is unable to find the declaration for ExitListener. If you just need to store the pointer of ExitListener in this class then there is no need to include the ExitListener.h header file. Instead you can just use the forward declaration as class ExitListener;

    EDIT: You can use the forward declaration as suggested above, or remove the InitialGameState.h include from ExitListener.h . You need to include GameState.h (the base class header file) only. But I prefer to use the forward declarations in header file and include the header file only in cpp.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a c++ header file containing a class. I want to use this
I have C++ project (VS2005) which includes header file with version number in #define
I have a flat-file schema that has a header and detail records. It looks
I have a PHP script that pushes the headers to allow a file to
I have my CSV file imported as such: records = FasterCSV.read(path, :headers => true,
Why does C++ have header files and .cpp files?
Based on the response to this question: Why does C++ have header files and
I have a header <h1>My Header</h1> It has a height of 150px and a
Lets say I have a header banner on a webpage I'm about to print.
Lets say that I have a header user control in a master page, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.