⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d_except.h

📁 clustering for ns-2 simulation
💻 H
字号:
#ifndef EXCEPTION_CLASSES#define EXCEPTION_CLASSES#include <iostream>#include <sstream>#include <string>using namespace std;class baseException{	public:		baseException(const string& str = ""):			msgString(str)		{			if (msgString == "")				msgString = "Unspecified exception";		}		string what() const		{			return msgString;		}	// protected allows a derived class to access msgString.	// chapter 13 discusses protected in detail	protected:		string msgString;};// failure to allocate memory (new() returns NULL)class memoryAllocationError: public baseException{	public:		memoryAllocationError(const string& msg = ""):			baseException(msg)		{}};// function argument out of proper rangeclass rangeError: public baseException{	public:		rangeError(const string& msg = ""):			baseException(msg)		{}};// index out of rangeclass indexRangeError: public baseException{	public:		indexRangeError(const string& msg, int i, int size):			baseException()		{			string indexString;			ostringstream indexErr(indexString);			indexErr << msg << "  index " << i << "  size = " << size << ends;			// indexRangeError can modify msgString, since it is in			// the protected section of baseException			msgString = indexString;		}};// attempt to erase from an empty containerclass underflowError: public baseException{	public:		underflowError(const string& msg = ""):			baseException(msg)		{}};// attempt to insert into a full containerclass overflowError: public baseException{	public:		overflowError(const string& msg = ""):			baseException(msg)		{}};// error in expression evaluationclass expressionError: public baseException{	public:		expressionError(const string& msg = ""):			baseException(msg)		{}};// bad object referenceclass referenceError: public baseException{	public:		referenceError(const string& msg = ""):			baseException(msg)		{}};// feature not implementedclass notImplementedError: public baseException{	public:		notImplementedError(const string& msg = ""):			baseException(msg)		{}};// date errorsclass dateError: public baseException{	public:		dateError(const string& first, int v, const string& last):			baseException()		{			string dateStr;			ostringstream dateErr(dateStr);			dateErr << first << ' ' << v << ' ' << last << ends;			// dateError can modify msgString, since it is in			// the protected section of baseException			msgString = dateStr;		}};// error in graph classclass graphError: public baseException{	public:		graphError(const string& msg = ""):			baseException(msg)		{}};// file open errorclass fileOpenError: public baseException{	public:		fileOpenError(const string& fname):			baseException()		{			string errorStr;			ostringstream fileErr(errorStr);			fileErr << "Cannot open \"" << fname << "\"" << ends;			// fileOpenError can modify msgString, since it is in			// the protected section of baseException			msgString = errorStr;		}};// error in graph classclass fileError: public baseException{	public:		fileError(const string& msg = ""):			baseException(msg)		{}};#endif	// EXCEPTION_CLASSES

⌨️ 快捷键说明

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