Moinmoin,
ich habe mich jetzt endlich an OOP in C++ in verbindung mit SDL rangetraut. Mein Problem ist, dass ich gerne einen boolischen (heißt das so ) im private-Bereich initalisieren würde. Doch wenn ich das versuche bekomm ich folgende Fehlermeldung:
...\SGSF\include\GameFunctions.h|14|error: a brace-enclosed initializer is not allowed here before '{' token|
...\SGSF\include\GameFunctions.h|14|error: ISO C++ forbids initialization of member 'keys'|
...\SGSF\include\GameFunctions.h|14|error: making 'keys' static|
...\SGSF\include\GameFunctions.h|14|error: invalid in-class initialization of static data member of non-integral type 'bool [323]'|
...\SGSF\include\GameFunctions.h||In member function 'void game::handleInput()':|
...\SGSF\include\GameFunctions.h|79|error: 'keys' was not declared in this scope|
...\SGSF\include\GameFunctions.h|84|error: 'keys' was not declared in this scope|
...\SGSF\include\GameFunctions.h|88|error: 'keys' was not declared in this scope|
...\SGSF\main.cpp||In function 'int SDL_main(int, char**)':|
...\SGSF\main.cpp|13|warning: no return statement in function returning non-void|
||=== Build finished: 7 errors, 1 warnings ===|
Code:
Alles anzeigen
Wenn ich den Array in der handle::input(); initalisiere läuft alles ohne Probleme. Wäre dankbar für Hilfe
ich habe mich jetzt endlich an OOP in C++ in verbindung mit SDL rangetraut. Mein Problem ist, dass ich gerne einen boolischen (heißt das so ) im private-Bereich initalisieren würde. Doch wenn ich das versuche bekomm ich folgende Fehlermeldung:
...\SGSF\include\GameFunctions.h|14|error: a brace-enclosed initializer is not allowed here before '{' token|
...\SGSF\include\GameFunctions.h|14|error: ISO C++ forbids initialization of member 'keys'|
...\SGSF\include\GameFunctions.h|14|error: making 'keys' static|
...\SGSF\include\GameFunctions.h|14|error: invalid in-class initialization of static data member of non-integral type 'bool [323]'|
...\SGSF\include\GameFunctions.h||In member function 'void game::handleInput()':|
...\SGSF\include\GameFunctions.h|79|error: 'keys' was not declared in this scope|
...\SGSF\include\GameFunctions.h|84|error: 'keys' was not declared in this scope|
...\SGSF\include\GameFunctions.h|88|error: 'keys' was not declared in this scope|
...\SGSF\main.cpp||In function 'int SDL_main(int, char**)':|
...\SGSF\main.cpp|13|warning: no return statement in function returning non-void|
||=== Build finished: 7 errors, 1 warnings ===|
Code:
Quellcode
- #include <string>
- #include <iostream>
- #include <cstdlib>
- #include "integer.h"
- using namespace std;
- class game
- {
- private:
- bool gameRunning;
- bool keys[323] = {false};
- SDL_Event event;
- public:
- game();
- void start();
- bool isRunning();
- void drawSprite(int sWidth, int sHeight, int xPos, int yPos, SDL_Surface* source, SDL_Surface* destination);
- void handleInput();
- void close();
- };
Wenn ich den Array in der handle::input(); initalisiere läuft alles ohne Probleme. Wäre dankbar für Hilfe