Thread: Cannot declare inherited class of virtual Base

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472

    Cannot declare inherited class of virtual Base

    Anybody see what is going wrong here? i am compiling using codeblocks, when i try to make the ResetState class inherit from the StateEngine class i get error

    "expected unqualified-id before "public"
    |
    ||=== Build finished: 1 errors, 0 warnings ===|

    other classes are working fine as inherited, and the project has been built ok,
    its only when i add the text to make resetstate inherit that the problem occurs
    i have cleaned and done rebuild also.

    i cant see what i am doing wrong,
    below is the base class, resetstate class and resetstate constructor

    Base Class in header Globals.h >

    Code:
    #ifndef GLOBALS_H_INCLUDED
    #define GLOBALS_H_INCLUDED
    
    #include <SDL/SDL_events.h>
    #include <SDL/SDL_image.h>
    
    extern SDL_Surface* screen;              
    extern SDL_Surface* temp;
    extern SDL_Event event;                  
    
    class StateEngine                               //Base class
    {
        public:
        virtual void HandleEvents() = 0;
        virtual void Do_Logic() = 0;
        virtual void Render() = 0;
        virtual ~StateEngine(){};
    };
    
    
    #endif // GLOBALS_H_INCLUDED
    ResetState Class in header reset.h >

    Code:
    #ifndef RESET_H_INCLUDED
    #define RESET_H_INCLUDED
    
    #include <SDL/SDL.h>
    #include <SDL/SDL_events.h>
    #include <SDL/SDL_image.h>
    #include "Constants.h"
    #include "Globals.h"
    
    class ResetState public : StateEngine
    {
        private:
    
        SDL_Surface* Resetsourcemsg; 
        SDL_Surface* Buttonsource;  
        SDL_Rect resetmsg;
        SDL_Rect resetclip;
        SDL_Rect optionbutton[2];
        SDL_Rect optionclip[2];
    
        int count;
        int anim_count;
        int testX, testY;
    
        public:
    
        void HandleEvents();
        void Do_Logic();
        void Render();
    
        ResetState();
        ~ResetState();
    
    };
    
    #endif // RESET_H_INCLUDED
    The Constructor for ResetState in source file of same name >

    Code:
    #include <SDL/SDL.h>
    #include <SDL/SDL_events.h>
    #include <SDL/SDL_image.h>
    #include "Utilities.h"
    #include "Constants.h"
    #include "Globals.h"
    #include "reset.h"
    
    ResetState::ResetState()
    {
        temp = NULL;                            //this is global
        Resetsourcemsg = NULL;
        Buttonsource = NULL;
    
        temp = SDL_LoadBMP("Gameinfo.bmp");
        Resetsourcemsg = SDL_DisplayFormat(temp);
        SDL_FreeSurface(temp);
    
        temp = SDL_LoadBMP("Buttonsheet.bmp");
        Buttonsource = SDL_DisplayFormat(temp);
        SDL_FreeSurface(temp);
    
        testX = 0, testY = 0;
        anim_count = 0;
    
        resetmsg.x = 330;            //the reset game yes/no? message box
        resetmsg.y = 580;
        resetmsg.w = 500;
        resetmsg.h = 100;
    
     //for the sake of brevity i have removed the rest of the constructor, it just 
     // initialises the remaining SDL_Rect objects as in above resetmsg.x = etc.
    
    }
    Last edited by rogster001; 12-17-2009 at 08:56 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 06-18-2009, 04:58 AM
  2. Declaring instances of different implementations
    By dwks in forum C++ Programming
    Replies: 8
    Last Post: 07-16-2008, 11:43 AM
  3. Replies: 3
    Last Post: 10-27-2006, 12:33 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM