제목에 언급 된 것처럼 왜이 오류가 발생하는지 잘 모르겠습니다. 나는이 구조와 비슷한 test.cpp를한데 모아 두었다. 또한 벡터 문제 이외에도 '보호 된'것에 대한 다른 문제가 있습니다. 이는 코드에도 없습니다. 나는 '보호 된'매크로라고 생각하는데, 거기에는 무엇이 있는지 알려주지 않습니다. 나는 QT를 처음 사용하기 때문에 "잘못하고있다"고 생각합니다. 확실히 컴파일러가 제안하는 것입니다.오류 도움말 : ISO C++에서 형식이없는 '벡터'선언을 금지합니다.
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.
다음은 코드입니다. 나는 그 오류에서 언급 된 줄에 번호를 매겼다.
#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
인류애를 위해서 헤더 파일에 "네임 스페이스 XXX 사용"을 사용하지 마십시오. 당신은 그것을 가로막는 모든 다른 프로그래머를 울게 만들 것이다. –
동의하지만 사람들에게 옵션을 알려주는 경우도 있습니다) – MichaelM
다음은이 옵션을 포함하는 것입니다 : std :: vector; 나는 .cpp에서 include 다음에 선호한다. 묶는 std :: 모든 곳에서 * 및 * 헤더가 포함 된 이유 (벡터의 경우처럼 항상 명확하지는 않음)를 저장합니다. –