I’ve been going through a tutorial on game programming using SDL when I encountered this error. I created a class called CApp with the header file below:
#ifndef CAPP_H_INCLUDED
#define CAPP_H_INCLUDED
#include <SDL/SDL.h>
class CApp{
private:
bool Running;
public:
CApp();
int OnExecute();
bool OnInit();
void OnEvent(SDL_Event* Event);
void OnLoop();
void OnRender();
void OnCleanup();
};
#endif // CAPP_H_INCLUDED
Here is the corresponding .cpp file:
#include "CApp.h"
CApp::CApp{
Running = true;
}
int CApp::OnExecute(){
if(OnInit() == false){
return -1;
}
SDL_Event Event;
while(Running){
while(SDL_PollEvent(&Event)){
OnEvent(&Event);
}
OnLoop();
OnRender();
}
OnCleanup();
return 0;
}
int main(int argc, char* argv[]){
CApp theApp;
return theApp.OnExecute();
}
The error happens on the line in the .cpp file that reads “CApp::CApp{“
I’m fairly new to C++ and even newer to SDL, so any help would be appreciated. I am using CodeBlocks IDE with mingw compiler
You are missing the parentheses that declare the construct to be a method/constructor.