Problem With {SDLTutorials.com}

closed account (N36fSL3A)
Well, hello... I have a problem. It's my code wont compile... It keeps giving me this:
1
2
3
4
5
6
7
8
9
10
11
1
1>  CSurface.cpp
1>  CApp_OnRender.cpp
1>  CApp_OnLoop.cpp
1>  CApp_OnInit.cpp
1>  CApp_OnEvent.cpp
1>c:\users\house\documents\visual studio 2010\projects\sdltuts2\sdltuts2\capp_onevent.cpp(7): error C2352: 'CEvent::OnEvent' : illegal call of non-static member function
1>          c:\users\house\documents\visual studio 2010\projects\sdltuts2\sdltuts2\cevent.h(13) : see declaration of 'CEvent::OnEvent'
1>  CApp_OnCleanup.cpp
1>  CApp.cpp
1>  Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

EDIT: The problem was that the compiler was complaining about an "illegal call of non-static member function"

Since my code is too big to post, I wont post all of it. You can find all the source on the website sdltutorials.com
Anyway here is some of the code.

CApp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//The main header

#ifndef _CAPP_H_     
#define _CAPP_H_

//Including SDL
#include <SDL.h>

//Including other header(s)
#include "CEvent.h"
#include "CSurface.h"

//Main Class
class CApp
{
	private:
		//This variable is true when the program is running but returns false when not.
		bool				Running;

		//Surface Variable(s)
		SDL_Surface*		Surf_Display;
		SDL_Surface*		Surf_Test;
	public:
		CApp();

		int OnExecute();

	public:

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

};   
#endif //_CAPP_H_ 


CEvent
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef _CEVENT_H_
#define _CEVENT_H_
 
#include <SDL.h>
 
class CEvent 
{
	public:
        CEvent();
 
        virtual ~CEvent();
 
        virtual void OnEvent(SDL_Event* Event);
 
        virtual void OnInputFocus();
 
        virtual void OnInputBlur();
 
        virtual void OnKeyDown(SDLKey sym, SDLMod mod, Uint16 unicode);
 
        virtual void OnKeyUp(SDLKey sym, SDLMod mod, Uint16 unicode);
 
        virtual void OnMouseFocus();
 
        virtual void OnMouseBlur();
 
        virtual void OnMouseMove(int mX, int mY, int relX, int relY, bool Left,bool Right,bool Middle);
 
        virtual void OnMouseWheel(bool Up, bool Down);    //Not implemented
 
        virtual void OnLButtonDown(int mX, int mY);
 
        virtual void OnLButtonUp(int mX, int mY);
 
        virtual void OnRButtonDown(int mX, int mY);
 
        virtual void OnRButtonUp(int mX, int mY);
 
        virtual void OnMButtonDown(int mX, int mY);
 
        virtual void OnMButtonUp(int mX, int mY);
 
        virtual void OnJoyAxis(Uint8 which, Uint8 axis, Sint16 value);
 
        virtual void OnJoyButtonDown(Uint8 which, Uint8 button);
 
        virtual void OnJoyButtonUp(Uint8 which, Uint8 button);
 
        virtual void OnJoyHat(Uint8 which, Uint8 hat, Uint8 value);
 
        virtual void OnJoyBall(Uint8 which, Uint8 ball, Sint16 xrel, Sint16 yrel);
 
        virtual void OnMinimize();
 
        virtual void OnRestore();
 
        virtual void OnResize(int w,int h);
 
        virtual void OnExpose();
 
        virtual void OnExit();
 
        virtual void OnUser(Uint8 type, int code, void* data1, void* data2);
};
 
#endif //_CEVENT_H_ 


Sorry I couldn't post all the code... but can you still please help???
Thanks in advance...



Last edited on by Fredbill30
Sounds like you are calling a non-static member functions like it was a static member function.
closed account (N36fSL3A)
But I ripped it straight from the tutorial, typed letter to letter... how do I fix this???
closed account (3hM2Nwbp)
c:\users\house\documents\visual studio 2010\projects\sdltuts2\sdltuts2\capp_onevent.cpp(7): error


Although compiler messages are somewhat cryptic, they sometimes point you in the right direction.

Line 7 of capp_onevent.cpp is where the issue is. Post it and all will be revealed.

* You'll notice when dealing with many free hobbyist libraries that documentation and examples often contain errors that the maintainers overlooked, or otherwise neglected to fix. It's annoying for sure, but you do get what you pay for as they say...
Last edited on
You didn't copy it correctly, on the site CApp inherits CEvent
closed account (N36fSL3A)
Thanks, naraku! You fixed my problem =D
EDIT I posted the problem, sorry....
Last edited on by Fredbill30
Topic archived. No new replies allowed.