errorcorrelator.cpp

来自「C++高级编程这本书所附的源代码」· C++ 代码 · 共 36 行

CPP
36
字号
#include "ErrorCorrelator.h"using namespace std;bool operator<(const Error& lhs, const Error& rhs){  return (lhs.mPriority < rhs.mPriority);}ostream& operator<<(ostream& str, const Error& err){  str << err.mError << " (priority " << err.mPriority << ")";  return (str);}void ErrorCorrelator::addError(const Error& error){  mErrors.push(error);}Error ErrorCorrelator::getError() throw (out_of_range){  //  // If there are no more errors, throw an exception.  //  if (mErrors.empty()) {    throw (out_of_range("No elements!"));  }    // Save the top element  Error top = mErrors.top();  // Remove the top element.  mErrors.pop();  // Return the saved element.  return (top);}

⌨️ 快捷键说明

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