1
此代碼給我下面的錯誤在該行My_grammar g;
:使用刪除功能的構造函數,沒有匹配的函數調用
no matching function for call to boost::spirit::qi::grammar<My_grammar>::grammar()’
use of deleted function ‘My_grammar::My_grammar()’
我不明白,是不是有應該是一個默認(未刪除)構造函數?但問題可能在其他地方。我會實現一個構造函數,但它會帶來新的錯誤,並且教程/例子從不使用相同的方法(一些使用構造函數,一些不使用),或者使用類,我也不知道文檔,編譯器或谷歌知道任何關於(CParser ??)。我認爲這可能是因爲我(不)包含的標題,因爲我可以在助推/精神下選擇很多。再一次,可能過時的教程中的人似乎沒有包括這些,或者使用那些昨天不存在的人,即易於獲取,最有可能是最新版本的boost。我使用Eclipse,以防它改變任何東西。
#include <iostream>
#include <cstdlib>
#include <string>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_rule.hpp>
using namespace boost::spirit;
#define BOOST_SPIRIT_DEBUG
struct My_grammar :
public boost::spirit::qi::grammar<My_grammar>
{
public:
template <typename ScannerT>
struct definition
{
public:
definition(My_grammar const& self)
{
sentence
= 'a';
}
boost::spirit::qi::rule<ScannerT> sentence;
boost::spirit::qi::rule<ScannerT> const& start() const { return sentence; }
};
};
int main() {
My_grammar g;
return EXIT_SUCCESS;
}
我覺得未來有更多的問題未來(例如:我已經嘗試和失敗的parse()函數),但我想解決這個問題一次一個。
這確實編譯。挑剔的時候,你不應該在聲明句子時使用你的名字空間嗎? – LogicalKip
啊我現在看到它。畢竟它是一樣的 – sehe