Я пытаюсь реализовать исключение и выбросить его из моего метода.ожидаемое первичное выражение перед ';' token
Вот h
файл за исключением
#ifndef EXCEPTION_H
#define EXCEPTION_H
#include <exception>
#include <string>
namespace core {
class no_implementation: public std::exception {
private:
std::string error_message;
public:
no_implementation(std::string error_message);
const char* what() const noexcept;
};
typedef no_implementation noimp;
}
#endif
А вот cpp
файл
#include "../headers/exception.h"
using namespace core;
no_implementation::no_implementation(std::string error_message = "Not implemented!") {
this->error_message = error_message;
}
const char* no_implementation::what() const noexcept {
return this->error_message.c_str();
}
А вот метод
std::string IndexedObject::to_string() {
throw noimp;
}
Но он показывает мне ошибку
throw noimp; //expected primary-expression before ';' token
В чем проблема?
Должно ли это быть «бросить no_implementation»? Ps используют 'const' и ссылки при передаче' std :: String' –