错误:ISO C++禁止声明无类型的'TimerExeption'
error: ISO C++ forbids declaration of 'TimerExeption' with no type
当我试图在timer.cpp文件中抛出TimerException类型的异常时,我得到了这个错误。下面是timer_exception.h
1 #ifndef TIMER_EXCEPTION_H
2 #define TIMER_EXCEPTION_H
3
4 #include <iostream>
5 #include <string>
6
7 class TimerException{
8 friend std::ostream &operator <<(std::ostream &os, const TimerException e){
9 std::cout << " *** TIMER EXCEPTION *** " << e.message;
10 return os;
11 }
12 public:
13 TimerExeption(std::string message) : message(message) {}
14 private:
15 std::string message;
16 };
17
18
19 #endif
这里是我的timer.cpp文件,其中TimerException正在被实例化
1 #include <ctime>
2 #include "timer.h"
3 #include "timer_exception.h"
4
5 void Timer::start(){
6 if(timer != 0) throw TimerException("Timer already started");
7 this->timer = clock();
8 }
简单的排版错误。你的构造函数名称中缺少了一个'c'。
13 TimerExeption(std::string message) : message(message) {}
// ^^^
构造函数有一个错别字。timerexception, c缺失
相关文章:
- ArduinoJson 6.15.2:JsonObject没有命名类型
- 防止主数据类型C++的隐式转换
- 大量序列中核苷酸类型的快速计数
- 如何从C++中的依赖类型中获得它所依赖的类型
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- 是否可以初始化不可复制类型的成员变量(或基类)
- 如何获取std::result_of函数的返回类型
- 从父命名空间重载类型
- 如果C++类在类方法中具有动态分配,但没有构造函数/析构函数或任何非静态成员,那么它仍然是POD类型吗
- 我想将一个对T类型的非常量左值引用绑定到一个T类型的临时值
- Openssl 1.1.1d无效使用不完整的类型"struct dsa_st"
- 访问者访问变体并返回不同类型时出错
- 在VS2010-VS2015下编译时,如何使用decltype作为较大类型表达式的LHS
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- C++ 雷神库 - 使用资源加载器类时出现问题(不命名类型)
- 模板元程序查找相似的连续类型名称
- 是否可以从int转换为enum类类型
- 构造函数正在调用一个使用当前类类型的函数
- 我应该使用什么来代替void作为变体中的替代类型之一
- 错误:ISO C++禁止声明无类型的'TimerExeption'