exceptions.h

来自「压缩包里有教材<<C++模式设计-基于QT4开源跨平台开发框架&gt」· C头文件 代码 · 共 37 行

H
37
字号
#ifndef EXCEPTIONS_H#define EXCEPTIONS_H//start/* a custom exception with no data */class SizeMatchError {  public:    SizeMatchError() {}    QString what() {        return "Size mismatch for Vector addition!";    }};/* a custom exception with data */class BadSizeError {  public:    BadSizeError(int sz): m_Sz(sz) {}    QString what() const {        return QString("Invalid size for Vector: %1").arg(m_Sz);    }    int m_Sz;};#include <stdexcept>using std::exception;/* a custom exception extending from std::exception */class RangeError : public exception {   public:    RangeError() {}    const char* what() const throw() { /* matches base class virtual signature */        return "Subscript out of range!";    }};//end#endif 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?