帮助错误:ISO C ++禁止宣布'矢量'没有类型 [英] Help with error: ISO C++ forbids declaration of 'vector' with no type

查看:207
本文介绍了帮助错误:ISO C ++禁止宣布'矢量'没有类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所示,我不知道为什么我得到这个错误。我把一个类似于这个结构的test.cpp放在一起,它工作正常。此外,除了向量问题,还有另一个问题受保护,这甚至不是在代码中。我认为保护是一个宏,所以没有告诉什么。我是新来的QT,所以我可能做错了。这肯定是编译器建议的。

As the title states, I'm not sure why I'm getting this error. I've put together a test.cpp that's similar to this structure, and it works fine. Also, other than the vector problem, there's the other problem about 'protected', which isn't even in the code. I think 'protected' is a macro, so no telling what's there. I'm new to QT, so I'm likely "doing it wrong." That's certainly what the compiler's suggesting.

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.

这里是代码。我已编号错误中注明的行。

Here's the code. I've numbered the lines noted in the error.

#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


推荐答案

驻留在std命名空间中。您必须执行以下操作之一:

Vector resides in the std namespace. You have to do one of the following:

使用命名空间前缀类型:

Prepend the type with the namespace:

std::vector<std::vector<char *> > chars;

告诉编译器您使用std命名空间中的向量

Tell the compiler you are using vector from the std namespace

using std::vector;
vector<vector<char *> > chars;

或者告诉编译器你使用std命名空间,请参阅评论)

Or, tell the compiler you are using the std namespace, which will bring in everything (not recommended, see comments)

using namespace std;

这篇关于帮助错误:ISO C ++禁止宣布'矢量'没有类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆