【发布时间】:2018-05-12 16:45:11
【问题描述】:
//头文件
#include <exception>
#ifndef CRYPTSERVEXCEPTION_H
#define CRYPTSERVEXCEPTION_H
class cryptServException
{
public:
//these are classes defined in a class
class CantOpenForEncryption : public std::exception
{
public:
const char* what();
};
class DecryptKeyMismatch : public std::exception
{
public :
const char* what();
};
#endif // CRYPTSERVEXCEPTION_H
有这个隐式构造函数给出错误我只是无法理解原因,因为我们可以将构造函数的主体留空,如果有一些代码可以放在其中我不知道它应该是什么,希望现在你有问题了。
//CPP文件
#include "cryptServException.h"
//rest are just classes that are for exceptions
cryptServException::cryptServException()
{
// this constructor declaration gives the error : definition of implicitly- declared 'constexpr myException::myException()'|
}
//this is just a class in another class
cryptServException::CantOpenForEncryption : public exception
{
public :
const char* what()
{
return " Can't Open File For Encryption ";
}
};
//this is just a class in another class
cryptServException::DecryptKeyMismatch : public exception
{
public :
const char* what()
{
return " Incorrect Decryption Key ";
}
};
我无法确定上述隐式构造函数的错误原因。
感谢帮助
您能否建议我是否在 .cpp 文件中添加一个构造函数,应该在它的主体中放置什么代码
【问题讨论】:
-
名称
exception在哪里定义? -
其实我是直接用c++的异常类
-
但是您没有包含定义该类的标头。
标签: c++ c++11 constructor header