gelöst: Fehlermeldung expected init-declarator
Verfasst: 13. Juni 2006 00:16
hi,
ich versuche eine Klasse mit dem Singleton-Pattern zu schreiben und eigentlich schreibe ich nur von funktionierenden Klassen ab:
aus irgendeinem Grund kriege ich dabei diese Fehlermeldung:
ich versuche eine Klasse mit dem Singleton-Pattern zu schreiben und eigentlich schreibe ich nur von funktionierenden Klassen ab:
Code: Alles auswählen
Deklaration:
class cConstants {
public:
static cConstants* self();
QString getArtBez(int);
int getArtID(QString);
private:
cConstants();
static QPointer<cConstants> _self;
QVector<QString> eigenschaftsArten;
}
Code: Alles auswählen
Implementierung:
#include "constants.h"
QPointer<cConstants> cConstants::_self = 0L;
//
cConstants* cConstants::self() {
if ( !_self )
_self = new cConstants();
return _self;
}
cConstants::cConstants() {
//
}
QString cConstants::getArtBez(int id) {
return eigenschaftsArten[id];
}
int cConstants::getArtID(QString value) {
return eigenschaftsArten.indexOf(value);
}mal abgesehen davon, dass ich keine Ahnung habe, was er mit dem overriding commands will - das hat er schon länger und kompiliert trotzdem was ich erwarte. Aber was sollen mir bitte die Fehlermeldungen sgen??Makefile.Debug:372: warning: overriding commands for target `build\.rcc\qrc_WERTer.cpp'
Makefile.Debug:323: warning: ignoring old commands for target `build\.rcc\qrc_WERTer.cpp'
src\constants.cpp:4: error: expected init-declarator before "cConstants"
src\constants.cpp:4: error: expected `,' or `;' before "cConstants"
src\constants.cpp:7: instantiated from here
C:\Qt\4.1.3\include\QtCore\..\..\src\corelib\kernel\qpointer.h:58: error: invalid static_cast from type `QObject*' to type `cConstants*'
src\constants.cpp:8: instantiated from here
C:\Qt\4.1.3\include\QtCore\..\..\src\corelib\kernel\qpointer.h:48: error: comparison between distinct pointer types `QObject*' and `cConstants*' lacks a cast
C:\Qt\4.1.3\include\QtCore\..\..\src\corelib\kernel\qpointer.h:48: error: no matching function for call to `QMetaObject::changeGuard(QObject**, cConstants*&)'
C:\Qt\4.1.3\include\QtCore\..\..\src\corelib\kernel\qobjectdefs.h:257: note: candidates are: static void QMetaObject::changeGuard(QObject**, QObject*)