2

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   

ここに、TimerException がインスタンス化されている私の timer.cpp ファイルがあります

  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 }       
4

2 に答える 2

5

単純なタイプミス。コンストラクターの名前に「c」がありません。

13         TimerExeption(std::string message) : message(message) {}
//               ^^^
于 2013-03-07T18:41:51.087 に答える
1

コンストラクターにタイプミスがあります。TimerException、c がありません。

于 2013-03-07T18:42:39.087 に答える