Original Post
Description Resource Path Location Type expected class-name before '{' token Enemy.h line 12 C/C++ Problem expected class-name before '{' token Laser.h line 13 C/C++ Problem expected class-name before '{' token Player.h line 14 C/C++ Problem make: *** SourceFiles/Main.o] Error 1 Hidden Cosmos line 0 C/C++ Problem I get the above errors in the following files: However, I didn't change these files at all and they used to build. Also, depending on the link order of my object files, I get different errors, mainly undefined references and such. To add more oddity to the problem, if I build the program, with //CODE1, rebuild with //CODE2, and then rebuild with //CODE1, it compiles and runs! Any one have a clue what's wrong?
#ifndef LASER_H_
#define LASER_H_
#include <map>
#include <string>
#include "Sprite.h"
#include "Player.h"
#include "Enemy.h"
class Player;
class Enemy;
class Laser : public Sprite
{
private:
float xVelocity;
float yVelocity;
bool playerLaser;
public:
Laser();
Laser(const Laser& laser);
Laser(std::string initialImagePath, float initialImageWidth, float initialImageHeight, float initalX, float initialY, float initialZ, float initialWidth, float initialHeight, float initialXVelocity, float initialYVelocity, bool initialPlayerLaser);
void move(float xVelocity, float yVelocity, std::vector<Player> &players, std::vector<Enemy> &enemies);
void move(std::vector<Player> &players, std::vector<Enemy> &enemies);
void setVelocities(float newXVelocity, float newYVelocity);
void setPlayerLaser(bool newPlayerLaser);
bool getPlayerLaser();
};
#endif
#ifndef ENEMY_H_
#define ENEMY_H_
#include "Sprite.h"
#include "Player.h"
#include "Laser.h"
#include "Path.h"
class Player;
class Laser;
class Enemy : public Sprite
{
private:
int currentPointIndex;
bool isFinishedOnPath;
public:
Enemy();
Enemy(std::string initialImagePath, float initialImageWidth, float initialImageHeight, float initalX, float initialY, float initialZ, float initialWidth, float initialHeight);
void move(float xVelocity, float yVelocity, std::vector<Player> &players, std::vector<Laser> &lasers);
void moveToPoint(Point p, std::vector<Player> &players, std::vector<Laser> &lasers);
void moveOnPath(Path &path, std::vector<Player> &players, std::vector<Laser> &lasers);
bool finishedPath(Path currentPath);
void shoot(float xVelocity, float yVelocity, std::vector<Laser> &lasers);
};
#endif
#ifndef PLAYER_H_
#define PLAYER_H_
#include <map>
#include <string>
#include "Globals.h"
#include "Sprite.h"
#include "Enemy.h"
#include "Laser.h"
class Enemy;
class Laser;
class Player : public Sprite
{
private:
int lives;
int invincibilityTicks;
public:
Player();
Player(std::string initialImagePath, float initialImageWidth, float initialImageHeight, float initalX, float initialY, float initialZ, float initialWidth, float initialHeight, int initialLives);
void move(float xVelocity, float yVelocity, std::vector<Enemy> &enemies, std::vector<Laser> &lasers);
void shoot(float xVelocity, float yVelocity, bool left, std::vector<Laser> &lasers);
int getLives() const;
void setLives(int newLives);
void setDead(bool newDead);
void resetCoordinates();
void incrementInvincibilityTicks();
bool invincible();
};
#endif
//CODE1
#ifndef GAME_STATE_H_
#define GAME_STATE_H_
#include <kos.h>
#include <map>
#include <vector>
#include <string>
#include "Player.h"
#include "Laser.h"
#include "Enemy.h"
#include "Level.h"
#include "Path.h"
#include "InputState.h"
#include "Init.h"
class GameState
{
private:
int numberOfPlayers;
bool paused;
int currentLevel;
int maxLevels;
int screen;
public:
GameState();
GameState(int initialNumberOfPlayers, bool initialPaused, int initialCurrentLevel, int initialMaxLevels);
void setNumberOfPlayers(int newNumberOfPlayers);
int getNumberOfPlayers() const;
void setPaused(bool newPaused);
bool getPaused() const;
void nextLevel();
int getCurrentLevel() const;
void setMaxLevels(int newMaxLevels);
int getScreen() const;
void setScreen(int newScreen,
pvr_ptr_t &titleScreenImage,
pvr_ptr_t &cursorImage,
InputState &inputState,
std::map<const std::string, pvr_ptr_t> &images,
std::vector<Player> &players,
std::vector<Laser> &lasers,
std::vector<Enemy> &enemies,
std::vector<Level> &levels,
std::vector<Path> &paths);
};
#endif
//CODE2
#ifndef GAME_STATE_H_
#define GAME_STATE_H_
#include <kos.h>
#include <map>
#include <vector>
#include <string>
class GameState
{
private:
int numberOfPlayers;
bool paused;
int currentLevel;
int maxLevels;
int screen;
public:
GameState();
GameState(int initialNumberOfPlayers, bool initialPaused, int initialCurrentLevel, int initialMaxLevels);
void setNumberOfPlayers(int newNumberOfPlayers);
int getNumberOfPlayers() const;
void setPaused(bool newPaused);
bool getPaused() const;
void nextLevel();
int getCurrentLevel() const;
void setMaxLevels(int newMaxLevels);
int getScreen() const;
};
#endif