/************************************************************************/
/*
File: exception.h
Author: WLW
Data: 2006.4.24
Purpose: Exception deal
*/
/************************************************************************/
#pragma once
#include <Windows.h>
#include <string>
using namespace std;
class Exception
{
public:
Exception(void){ strError = "Unknown Exception!/r/n"; }
Exception(const Exception &e) { strError = e.strError; }
Exception(const char *pcszError){ strError = pcszError; }
~Exception(void) {}
void ThrowException(void) const { OutputDebugString(strError.c_str()); }
void ThrowException(const char *pcszError) const { OutputDebugString(pcszError); }
const string Description(void) const { return strError; }
private:
string strError;
};
///
int _tmain(int argc, _TCHAR* argv[])
{
try
{
int i = 3;
if (i < 4)
{
throw Exception("less number/r/n");
}
}
catch (Exception e)
{
e.ThrowException();
return 0;
}
return 1;
}