【发布时间】:2016-05-25 21:54:45
【问题描述】:
我遇到了一个奇怪的问题。 首先,这是我的代码:
#ifndef REGEX_H
#define REGEX_H
#include <regex>
/****************************** REGEX *************************/
class MyRegex {
regex reg;
StrategieLitteraux* strategie;
public :
MyRegex(regex _reg, StrategieLitteraux* _strategie) : reg(_reg), strategie(_strategie) {}
virtual ~MyRegex() {}
void execute(Pile& pile,const QString& s) { strategie->execute(pile,s); }
regex getRegex() const {return reg;}
};
/*******************************************************************/
#endif // REGEX_H
我收到了这个错误:
'regex' 没有命名类型
我不知道我做错了什么。有谁有想法吗 ?我以前已经使用过正则表达式,但这次我无法让它工作。谢谢
【问题讨论】:
-
你需要
std::regex。 -
您正在寻找
std::regex。附:我要祝贺你避免了名为“using namespace std;”的令人讨厌的癌症。 -
谢谢!我在 Qt 上,看起来我什至不需要 std::regex。我只需要包含“strategie.h”,它就可以识别正则表达式。我不知道为什么,但如果我遇到这个错误,我会使用 std::regex :) 编辑:实际上我知道,strategie.h 包括 computer.h,它使用“使用名称 std”。我将删除这一行。