c++异常处理机制示例及讲解...
时间:2010-08-17 来源:y84161838
下面的代码直接贴到你的console工程中,可以运行调试看看效果,并分析c++的异常机制。
#include "stdafx.h"
#include
#include
#include
// 内存泄露检测机制
#define _CRTDBG_MAP_ALLOC
#ifdef _DEBUG
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
#endif
// 自定义异常类
class MyExcepction
{
public:
// 构造函数,参数为错误代码
MyExcepction(int errorId)
{
// 输出构造函数被调用信息
std::cout
相关阅读 更多 +