Tôi đang cố gắng để biên dịch này với g ++ dưới Ubuntu:biên dịch báo lỗi khi cố gắng để kế thừa từ std :: runtime_error
#ifndef PARSEEXCEPTION_H
#define PARSEEXCEPTION_H
#include<exception>
#include<string>
#include<iostream>
struct ParseException : public std::runtime_error
{
explicit ParseException(const std::string& msg):std::runtime_error(msg){};
explicit ParseException(const std::string& token,const std::string& found):std::runtime_error("missing '"+token+"',instead found: '"+found+"'"){};
};
#endif
tôi nhận được lỗi thông điệp:
In file included from parseexception.cpp:1:
parseexception.h:9: error: expected class-name before ‘{’ token
parseexception.h: In constructor ‘ParseException::ParseException(const std::string&)’:
parseexception.h:10: error: expected class-name before ‘(’ token
parseexception.h:10: error: expected ‘{’ before ‘(’ token
parseexception.h: In constructor ‘ParseException::ParseException(const std::string&, const std::string&)’:
parseexception.h:11: error: expected class-name before ‘(’ token
parseexception.h:11: error: expected ‘{’ before ‘(’ token
enter code here
Tôi có đã gặp vấn đề này đôi khi và tôi không thể thực sự hiểu sai điều gì với nó:/
cảm ơn rất nhiều Nikko: D – SlimJim
+1 cho lời khuyên của người cha :) – Chani