小弟在调一个VC++技术内幕(第四版)的ex28a程序时,没有什么语法错误,但却弹出一个窗口,信息如下:
Debug Assertion Failed!
Program:D:\ex28a\Debug\ex28a.exe
File:afxdb.inl
Line:48
For information on how your program can cause an assertion failure,see the Visual C++ documentation on asserts.
(press Retry to debug the application)
还有三个按钮,分别为:
终止(A) 重试(R) 忽略(I)
当我按了重试按钮时,又弹出一个窗口,信息如下:
应用程序发生异常 unknown software exception(0x80000003),位置为0x5f70b341。
要终止程序,请单击“确定”。
要调试程序,请单击“取消”。
还有“确定”按钮和“取消”按钮请问这是怎么回事啊?是什么错误啊,但却没语法错误,也没逻辑错误啊,因为我是照着书上的例题抄的啊??????帮帮忙啊,100分不够再发帖子
Debug Assertion Failed!
Program:D:\ex28a\Debug\ex28a.exe
File:afxdb.inl
Line:48
For information on how your program can cause an assertion failure,see the Visual C++ documentation on asserts.
(press Retry to debug the application)
还有三个按钮,分别为:
终止(A) 重试(R) 忽略(I)
当我按了重试按钮时,又弹出一个窗口,信息如下:
应用程序发生异常 unknown software exception(0x80000003),位置为0x5f70b341。
要终止程序,请单击“确定”。
要调试程序,请单击“取消”。
还有“确定”按钮和“取消”按钮请问这是怎么回事啊?是什么错误啊,但却没语法错误,也没逻辑错误啊,因为我是照着书上的例题抄的啊??????帮帮忙啊,100分不够再发帖子
void CEx28aView::OnDraw(CDC* pDC)
{
TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
int nLineHeight=tm.tmHeight+tm.tmExternalLeading;
CPoint pText(0,0);
int y=0;
CString str;
if(m_pSet->IsBOF()){
return;
}
m_pSet->MoveFirst();
while(!m_pSet->IsEOF()){
str.Format("%ld", m_pSet->m_StudentID);
pDC->TextOut(pText.x,pText.y,str);
pDC->TextOut(pText.x+1000,pText.y,m_pSet->m_Name);
str.Format("%d",m_pSet->m_GradYear);
pDC->TextOut(pText.x+4000,pText.y,str);
m_pSet->MoveNext();
pText.y-=nLineHeight; }
}void CEx28aView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate(); CSize sizeTotal(8000,10500);
// TODO: calculate the total size of this view
sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_HIENGLISH, sizeTotal);
m_pSet=&GetDocument()->m_ex28aSet;
if(m_pSet->IsBOF()){
m_pSet->Close();
}
m_pSet->Open();
}
这是加上去的源程序
你从
File:afxdb.inl
Line:48
就可以看到这什么错误,如ASSERT(a>0), 那就表示a本来是应该大于0的,
但程序运行到这里时a却小于等0了。
ASSERT(exp) //断言exp为真
ASSERT_VALID(pObj) //断言pObj有效
。运行你的程序时不要点!而是点!旁边的那个东东,
出来断言错误后点重试, 代码就会跳到断言出错的地方。断言是一个非常好用的防错和查错工具。
可能是这里出问题:
if(m_pSet->IsBOF()){
m_pSet->Close();
}
m_pSet没有OPEN