First a small question: Can I use classes without creating an object?
I use a FrameBase abstract class and I have a few classes based on this BaseFrame class. Than I have a pointer that points to the BaseFrame class and I want to let this pointer point to the classes based on this FrameBase class.
(LoadFrame is a class based on BaseFrame)
So:
FrameBase *fpointer;
Fpointer = &LoadFrame; // Here the pointer will point to the loadframe class
Fpointer->Frame() //The Frame method is included in all classes based on BaseFrame
My problems:
(from the debugger)
- expected class-name before '{' token
My class HAS a name!
This is my class from the headerfile loading.h:
class LoadFrame : public FrameBase
{
private:
void Loop();
int id;
protected:
public:
//Public Methods
int get_id();
void Frame();
//Constructor
LoadFrame();
};
My second problem:
- expected primairy-expression before ';' token.
(main.cpp line 64)
This is my main.cpp:
/Including header files
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include "SDL.h"
#include "SDL_ttf.h"
#include "SDL_mixer.h"
#include "SDL_image.h"
//Including the main.h header files which includes the BaseFrame initialization
#include "main.h"
//Using the standard namespace
using namespace std;
//Static variables
SDL_Surface *screen; //The screen surface
FrameBase *Fpointer = NULL; //This pointer can point to all classes based on FrameBase
//Main starts here
int main(int argc, char** argv)
{
Fpointer = &LoadFrame;
//Start General Gameloop
bool run = true;
while(run == true)
{
Fpointer->Frame();
}
delete Fpointer;
//Game ends
return 0;
}
I hope someone can help me.
Greetings,
Rob
(PS my game isn't finished but I decided to debug it now since there will probably be too many bugs when it's finished so I can better fix the bugs I have now so I have less bugs when the game is completed)