Basic Question about OOP

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Das Gurke
Posts: 21
Joined: Sun Mar 05, 2006 7:39 pm

Basic Question about OOP

Post by Das Gurke »

I want to make a little GUI for my game and made so far no use of Object Orientation. I guess I understood the basics but now I am at a sort of dead point.

I divided my source into multiple Files and don't quite get the hang on how to do this with the IrrEventReceiver Class. My Code:

[CPP]

Code: Select all

#include "Irrlicht_Defs.h"
#include "IrrLoadScreen.h"
#include "Bomberman_Defs.h"
#include "Bomberman.h"
#include "INI.h"
#include "Graphics.h"
#include "IrrExtern.h"
#include "IrrEventReceiver.h"

//##############################################################################

class IrrEventReceiver
{
public:
	virtual bool OnEvent(irr::SEvent event)
	{
		if (event.EventType == irr::EET_GUI_EVENT)
		{
			irr::s32 id = event.GUIEvent.Caller->getID();
			irr::gui::IGUIEnvironment* env = IrrDevice->getGUIEnvironment();

            switch(event.GUIEvent.EventType)
            {
			case irr::gui::EGET_BUTTON_CLICKED:
              if (id == 101)
              {

              }
          }
       }
    }
 };
[H]

Code: Select all

#ifndef IRREVENTRECEIVER_H
#define IRREVENTRECEIVER_H

class IrrEventReceiver : public irr::IEventReceiver
{
	public:
		virtual bool OnEvent(irr::SEvent event);
};

#endif IRREVENTRECEIVER_H
Error is:
Class Type redefinition, so I just left the class out in the CPP, leads to different errors.

Hope somebody understands me to point to the correct direction.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

Ok learn c++

.cxx

Code: Select all

 #include "Irrlicht_Defs.h"
#include "IrrLoadScreen.h"
#include "Bomberman_Defs.h"
#include "Bomberman.h"
#include "INI.h"
#include "Graphics.h"
#include "IrrExtern.h"
#include "IrrEventReceiver.h"

//##############################################################################
   virtual bool IrrEventReceiver::OnEvent(irr::SEvent event)
   {
      if (event.EventType == irr::EET_GUI_EVENT)
      {
         irr::s32 id = event.GUIEvent.Caller->getID();
         irr::gui::IGUIEnvironment* env = IrrDevice->getGUIEnvironment();

            switch(event.GUIEvent.EventType)
            {
         case irr::gui::EGET_BUTTON_CLICKED:
              if (id == 101)
              {

              }
          }
       }
    }
.h

Code: Select all

the header was right
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Das Gurke
Posts: 21
Joined: Sun Mar 05, 2006 7:39 pm

Post by Das Gurke »

Mhm, not quite :(

Code: Select all

.\bomberman\IrrEventReceiver.cpp(13) : error C2723: 'IrrEventReceiver::OnEvent' : 'virtual' storage-class specifier illegal on function definition
Guess I really should start off with OOP :roll:
hybrid

Post by hybrid »

Or just do what the compiler tells you and test again. So remove the virtual in front of the method and it should work. But yes, without knowledge of C++ you're damn lost here.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

sry forgot to remove the virtual..... :oops: while telling u to learn c++
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Post Reply