Comme l'indique le titre, je ne sais pas pourquoi j'obtiens cette erreur. J'ai mis en place un test.cpp similaire à cette structure, et ça fonctionne très bien. De plus, à part le problème du vecteur, il y a l'autre problème concernant 'protected', qui n'est même pas dans le code. Je pense que "protégé" est une macro, donc pas de dire ce qu'il y a. Je suis nouveau à QT, donc je suis probablement "mal fait". C'est certainement ce que suggère le compilateur.Aide en cas d'erreur: ISO C++ interdit la déclaration de 'vecteur' sans type
In file included from DrvCrystalfontz.cpp:8:
LCDText.h:28: error: ISO C++ forbids declaration of 'vector' with no type
LCDText.h:28: error: expected ';' before '<' token
LCDText.h:30: error: ISO C++ forbids declaration of 'vector' with no type
LCDText.h:30: error: expected ',' or '...' before '<' token
LCDText.h:46: error: expected ':' before 'protected'
LCDText.h: In constructor 'LCDText::LCDText(int, int, int, int, int, int, int, QObject*)':
LCDText.h:33: error: expected '{' at end of input
scons: *** [DrvCrystalfontz.o] Error 1
scons: building terminated because of errors.
Voici le code. J'ai numéroté les lignes notées dans l'erreur.
#ifndef __LCD_TEXT__
#define __LCD_TEXT__
#include <vector>
#include <QObject>
#include "LCDBase.h"
#include "WidgetText.h"
#include "WidgetBar.h"
#include "WidgetHistogram.h"
#include "WidgetIcon.h"
#include "WidgetBignums.h"
#include "WidgetGif.h"
class LCDText: public LCDBase, public virtual QObject {
Q_OBJECT
protected:
char *LayoutFB;
char *DisplayFB;
int GOTO_COST;
int CHARS;
int CHAR0;
int LROWS;
int LCOLS;
int DROWS;
int DCOLS;
vector<vector<char *> > chars; // Line 28
void (*TextRealWrite) (const int row, const int col, const char *data, const int len);
void (*TextRealDefchar) (const int ascii, const vector<char *> matrix); // Line 30
public:
LCDText(int rows, int cols, int xres, int yres, int _goto, int chars,
int char0, QObject *parent) : LCDBase(xres, yres), QObject(parent); // Line 33
~LCDText();
void TextInit(int rows, int cols);
void TextBlit(int row, int col, int height, int width);
void TextClear();
void TextClearChars();
void TextGreet();
void TextDraw(WidgetText widget);
void TextBarDraw(WidgetBar widget);
void TextHistogramDraw(WidgetHistogram widget);
void TextIconDraw(WidgetIcon widget);
void TextBignumsDraw(WidgetBignums widget);
void TextGifDraw(WidgetGif widget);
public signals: // Line 46
void SpecialCharChanged(int ch);
public slots:
void TextSpecialCharChanged(int ch);
};
#endif
S'il vous plaît, pour l'amour de l'humanité, ne pas "using namespace XXX" dans un fichier d'en-tête. Vous ferez pleurer tous les autres programmeurs qui le rencontrent. –
D'accord, mais vous pouvez aussi bien dire aux gens les options;) – MichaelM
Eh bien, incluez cette option: en utilisant std :: vector; Je préfère dans le .cpp immédiatement après l'inclure. Enregistre std :: tous les documents sur place * et * pourquoi l'en-tête a été inclus (ce qui n'est pas toujours aussi évident que dans le cas d'un vecteur). –