0

When I try to call OnLoop I get error that it doesn't recognise it.

///Ins_App.h

#ifndef INS_APP_H
#define INS_APP_H

#include <SDL/SDL.h>

class Ins_App
{
    private:
        /*   Variables   */
        bool Running;
        SDL_Surface* Surf_Display;

    public:
        /*  inMain  */
        Ins_App();
        int OnExecute();

    public:
        /*  Other   */

        bool OnInit();
        void OnEvent(SDL_Event* Event);
        void OnLoop();
        void OnRender();
        void OnCleanup();

    protected:
};

#endif // INS_APP_H

///Ins_App.cpp

#include "Ins_App.h"

Ins_App::Ins_App()
{
    Running = true;
    Surf_Display = NULL;
}

int Ins_App::OnExecute(){

    if(OnInit() == false){
        return -1;
    }
    SDL_Event Event;
    while(Running){
        while(SDL_PollEvent(&Event)){
            OnEvent(&Event);
        }
        OnLoop();
        OnRender();
    }
    return 0;
}

int main(int argc, char* argv[]){

    Ins_App iApp;
    return iApp.OnExecute();

}

///OnLoop.cpp

#include "Ins_App.h"

void OnLoop(){

}

And here is the error:

obj\Debug\src\Ins_App.o:C:\Users\Al\Documents\Ins \src\Ins_App.cpp|19|undefined reference to `Ins_App::OnLoop()'|

What am I doing wrong?

1 Answer 1

9

You didn't define your member:

void OnLoop(){

}

should be

void Ins_App::OnLoop(){

}

You're basically just defining a free function named OnLoop, not your member.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.