关于异常的小程序出现debug assertion failed!错误的原因是什么?
2008-03-19 19:33
756 查看
#include<iostream.h>
#include<string.h>
class MyException
{
public:
char *cause;
MyException(char *in)
{
cause=new char[21];
strcpy(cause,in);
}
void printmessage()
{
cout<<"Error!"<<cause<<endl;
delete[] cause;
}
~MyException()
{
delete[] cause;
}
};
class person
{ int age;
public:
void get()
{
cout<<"Enter age:"<<endl;
cin>>age;
MyException e("Problem with age!");
if(age>100||age<0)
throw e;
else
cout<<"Correct age. : )";
}
};
void main()
{
person pe;
try
{
pe.get();
}
catch(MyException &x)
{
x.printmessage();
}
}
vc6.0编译通过,运行:当输入0-100之间的数时运行正常,当输入〉100的数时程序报错:
debug assertion failed!
program:c:/documents and settings/administor/debug/excep_test.exe
file:dbgdel.cpp
line:47
expression: _BLOCK_TYPE_IS_VAILD(pHead->nBlockUse)
不知为何出现这个错误???
#include<string.h>
class MyException
{
public:
char *cause;
MyException(char *in)
{
cause=new char[21];
strcpy(cause,in);
}
void printmessage()
{
cout<<"Error!"<<cause<<endl;
delete[] cause;
}
~MyException()
{
delete[] cause;
}
};
class person
{ int age;
public:
void get()
{
cout<<"Enter age:"<<endl;
cin>>age;
MyException e("Problem with age!");
if(age>100||age<0)
throw e;
else
cout<<"Correct age. : )";
}
};
void main()
{
person pe;
try
{
pe.get();
}
catch(MyException &x)
{
x.printmessage();
}
}
vc6.0编译通过,运行:当输入0-100之间的数时运行正常,当输入〉100的数时程序报错:
debug assertion failed!
program:c:/documents and settings/administor/debug/excep_test.exe
file:dbgdel.cpp
line:47
expression: _BLOCK_TYPE_IS_VAILD(pHead->nBlockUse)
不知为何出现这个错误???
相关文章推荐
- Debug Assertion Failed! 错误解决 (关于文件文件写入程序)
- MFC程序出现“Debug Assertion Failed! File:dlgdata.cpp Line: 43 ”错误
- Problem: 程序运行时,出现错误提示 Debug Assertion Failed! Program: d:\Program\Prg.exe File: f:\rtm\vctools\vc7libs\ship\atlmfc\include\afxwin1.inl Line: 24
- MFC程序出现“Debug Assertion Failed! File:dlgdata.cpp Line: 43 ”错误
- MFC程序出现“Debug Assertion Failed! File:afx.inl Line:177”错误
- MFC程序出现“Debug Assertion Failed! File:afx.inl Line:177”错误
- 关于 debug assertion failed, file:dlgdata.cpp,line"44 错误收藏
- 关于 debug assertion failed, file:dlgdata.cpp,line"43 错误解析
- Debug Assertion Failed!错误 关于m_File.m_hFile != NULL 和m_File.m_hFile != CFile::hFileNull 问题
- Debug Assertion Failed!错误 关于m_File.m_hFile != NULL 和m_File.m_hFile != CFile::hFileNull 问题
- MFC:“Debug Assertion Failed!” ——自动生成的单文档程序项目编译运行就有错误
- C/C++出现Debug Assertion Failed!错误
- 用vs2017编写opencv程序,出现下列错误OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow
- 组件注册失败( 出现Debug Assertion Failed!错误)
- 关于 debug assertion failed, file:dlgdata.cpp,line"44 错误
- 编译后运行,出现debug assertion failed!错误并转到ProcessShellCommand 函数
- MFC:“Debug Assertion Failed!” ——自动生成的单文档程序项目编译运行就有错误
- 关于对话框DoModal()函数调用失败的原因分析(Debug Assertion Failed)
- 有些情况下vc6.0 MFC程序运行时出现Debug Assertion Failed 的解决方法
- VC Debug Assertion failed错误常见原因分析