Hi,

I have not used C++ in about a year (Been using C# a lot lately ;))

I am receiving an error when I try to compile a new OpenGL project I am working on and I can't see where I have gone wrong, though i wouldn't be surprised if I have done something the C# way instead of the C++ way.

Anyway, here is the error:

File: GameEngine.h
Line: 28
Message: 'GameScreen' was not declared in this scope

Here is the contents of GameEngine.h:

#ifndef GAMEENGINE_H
#define GAMEENGINE_H

#include "GameScreen.h"

#include <SDL.h>
#include <SDL_opengl.h>
#include <GL/glu.h>
#include <vector>

//The main class in the game. Makes sure everything gets called at the right time and inits all other parts of the game.
class GameEngine
{
    public:
        GameEngine();                           //Constructor
        ~GameEngine();                          //Destructor
        bool Initialize();                      //Tell init OpenGL/SDL and tell main if the engine can be Run
        void Run();                             //This contains the game loop

        bool QuitGame;                          //Set to true to quit the game

    protected:
        void Process();                         //Processes all the input
        void Update();                          //Does animations and update physics type stuff
        void Draw();                            //Draws the scene
        void Resize(int Width, int Height);     //Handles the resize event

        std::vector<GameScreen *> GameScreens;  //A list of GameScreen pointers
};

#endif

and here is the code for GameScreen.h:

#ifndef GAMESCREEN_H
#define GAMESCREEN_H

#include "GameEngine.h"
#include "GameObject.h"

#include <SDL.h>
#include <vector>

//This is the base class for all the game screens: Menu's, pause screens, the UI and the game world
class GameScreen
{
    public:
        GameScreen();                                       //Constructor
        virtual ~GameScreen();                              //Destructor
        virtual void Process(SDL_Event *tmpEvent);          //Processes input and other events
        virtual void Update();                              //Updates things like physics and animation
        virtual void Draw();                                //Renders the screen

    protected:
        GameEngine *Parent;                                 //Pointer to the GameEngine - Allows us to modify QuitGame from this class
        std::vector<GameObject *> GameObjects;              //A list of GameObject pointers
};

#endif

Thanks.

hi everyone im new to c++ (im in my second semester) and i have a question about some errors im getting. I am using the vi editor and i am getting the following two errors:

assign2.cpp:39: error: âDATAFILEâ was not declared in this scope
assign2.cpp:40: error: âOUTFILEâ was not declared in this scope
here is my code:

#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

const int NAMESIZE=11;
const int FILENAMESIZE=51;
typedef char NAME_t[NAMESIZE];
typedef int GRADE_t;
typedef char FILENAME_t[FILENAMESIZE];
typedef fstream DATAFILE_t;
typedef fstream OUTFILE_t;

class cStudent
{
        private:
                NAME_t fname;
                NAME_t lname;
                GRADE_t t1;
                GRADE_t t2;
                GRADE_t t3;
                GRADE_t t4;
                GRADE_t assigngrade;
                GRADE_t examgrade;
        public:
                cStudent();

};//end class

void READ(DATAFILE_t &DATAFILE);
void PRINT(OUTFILE_t &OUTFILE);
void Finalize(DATAFILE_t &DATAFILE, OUTFILE_t &OUTFILE);
main()
{


        cStudent tempstudent;
        cStudent::cStudent();
        READ(DATAFILE);
        PRINT(OUTFILE);
        Finalize(DATAFILE,OUTFILE);

}//end main

void READ(DATAFILE_t &DATAFILE)
{
        FILENAME_t inputfile;
        cout<<"Enter the name of the data file:"<<endl;
        cin>>inputfile;
        DATAFILE.open(inputfile,ios::in);

};

void PRINT(OUTFILE_t &OUTFILE)
{
        FILENAME_t outputfile;
        cout<<"Enter the name of the output file to be created:"<<endl;
        cin>>outputfile;
        OUTFILE.open(outputfile,ios::out);

};

void Finalize(DATAFILE_t &DATAFILE, OUTFILE_t &OUTFILE)
{
        cout<<"Now closing input and output files...."<<endl;
        DATAFILE.close();
        OUTFILE.close();
        cout<<"Terminating program.....GOODBYE..."<<endl;
};

can anyone help me because I am very much stuck

thanks!!!

For Tariban, try
std::vector<GameScreen*> *GameScreens; //A list of GameScreen pointers (note the second star).

I've also always put my includes outside of the class define hash; not sure if this would cause a problem, or indeed which way is correct but it might be worth a try putting them outside if it still doesn't work...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.