I have this code: class GameEvent : public wxEvent { public: GameEvent(wxEventType…
Jump to turn (8)
- 1I have this code: class GameEvent : public wxEvent { public: GameEvent(wxEventTy
- 2in another instance of yourself, you gave me this answer: To handle three possib
- 3how do I connect wxEVTCUSTOMCHILDFRAMECLOSED to my event and my method?
- 4it is giving me error: class GameEvent : public wxEvent { public: GameEvent(wxEv
- 5It is giving me errors now: //GameEvent.h class GameEvent : public wxEvent { pub
- 6I di your changes and it is giving me the same error, is there a different way t
- 7it doesn't give me errors now but when I run it it doesn't fire the event, here
- 8Now it enters the the event and it is fired but the cast to the game event gives
- User
I have this code:
class GameEvent : public wxEvent { public: GameEvent(wxEventType eventType=wxEVT_NULL, int id=0); virtual ~GameEvent(); void SetGame(Game* game); Game* GetGame() const; void SetGameEventType(GameEventType gameEventType); GameEventType GetGameEventType(); wxEvent* Clone() const override { return new GameEvent(this); }
private: Game* game; GameEventType gameEventType; };
But is giving me errors in the Clone method, the error is this: include\GameEvent.h|18|error: invalid conversion from ‘const GameEvent*’ to ‘wxEventType’ {aka ‘int’} [-fpermissive]|
- Assistant
The error you are encountering is due to an incorrect conversion in the Clone method. The Clone method returns a new instance of GameEvent, so you need to explicitly cast the pointer to 'wxEventType' in the return statement. Here's the modified code: