I have a class named backgroundObstacleManager that I created and another class Pit that have to interact with each other however I'm getting an error.
//backgroundobstacleManager.h
#include "Pit.h"
class backgroundObstacleManager
{
public:
backgroundObstacleManager();
void update(sf::RenderWindow *app, Player *Jerry);
int getGroundHeight() {return sprite[0].getGlobalBounds().height;}
virtual ~backgroundObstacleManager();
protected:
private:
sf::Texture texture;
sf::Sprite sprite[100];//these sprites point to same image and using many sprites
//presented greater advantages than moveing it then redrawing
bool atBeginning; //if atBeginning == true then level needs to be init
//lenght of all backgrounds are 6400 pixals(but stops at 5500) with increasing obstacles with each passed
Pit pit; //THIS LINE GIVING ERROR
};
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Pit.h
class Pit
{
public:
Pit();
int begining;
int ending; //begining and end of the pit
int height; //height of the ledge above to jump on
void update(int heightOfGround); //in what way does the pit affect player(change to falling or etc.)
protected:
private:
};
The error is
/media/justin/Linux Data/Programming/C++/jerry and the magic bannana/backgroundObstacleManager.h|34|error: ‘Pit’ does not name a type|
anyone have any suggestions?
I found a solution on stackOverflow. For anyone who might have this problem in the future google "forward declaring c++" and you can find a solution pretty easy