I'm not allowed to make any definition in the header file, only declarations. So I have the following .h file:
class read_error final: public std::runtime_error {
public:
enum class Code: uint8_t;
read_error(Code code);
Code getCode() const throw();
private:
Code code;
static std::string whatFromCode(Code code);
};
And in the .cpp file I want to do this:
enum class read_error::Code: uint8_t {
TIME_OUT,
DESERIALIZE,
CHECKSUM,
START_BYTE,
END_BYTE,
COMMAND
};
And I mean, that part does compile, but when I try to throw this error like read_error(read_error::Code::CHECKSUM);
I get the the following: error: ‘CHECKSUM’ is not a member of ‘amp::exception::read_error::Code’
I put both the cpp and the h into my makefile but it doesn't seem to find the definition. Is there any other way than defining the enum class in the .h file?
Aucun commentaire:
Enregistrer un commentaire