相关疑难解决方法(0)

帮助解决错误:ISO C++禁止声明'vector'没有类型

正如标题所述,我不确定为什么我会收到此错误.我已经整理了一个类似于这个结构的test.cpp,它运行正常.另外,除了向量问题之外,还有另一个关于'protected'的问题,即使在代码中也是如此.我认为'protected'是一个宏,所以不知道那里有什么.我是QT的新手,所以我很可能"做错了." 这肯定是编译器的建议.

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 …
Run Code Online (Sandbox Code Playgroud)

c++ vector

11
推荐指数
1
解决办法
6万
查看次数

ISO C++禁止在没有类型的情况下声明'vector'

当我编译我的项目时,我得到了tools.h/tools.h的奇怪错误.字符串和向量类通过std命名空间使用.我只是看不出任何错误.

g++ powerpi.cpp structs.cpp xmlreader.cpp tools.cpp -o powerpi
In file included from structs.cpp:5:
tools.h:5: error: ISO C++ forbids declaration of ‘vector’ with no type
tools.h:5: error: invalid use of ‘::’
tools.h:5: error: expected ‘;’ before ‘<’ token
Run Code Online (Sandbox Code Playgroud)

的Tools.h

class Tools {
  public:
    template<typename T>
    static std::string convert(T);
    static std::vector<std::string> explode(std::string, std::string);
};
Run Code Online (Sandbox Code Playgroud)

tools.cpp

#include <sstream>
#include <vector>
#include <string>

#include "tools.h"

template <typename T>
std::string Tools::convert(T Number)
{ 
  std::ostringstream ss;
  ss << Number;
  return ss.str();
}

std::vector<std::string> Tools::explode(std::string delimiter, std::string …
Run Code Online (Sandbox Code Playgroud)

c++ g++

1
推荐指数
1
解决办法
9497
查看次数

标签 统计

c++ ×2

g++ ×1

vector ×1