在xxdoc.cpp里做成以下函数:以取得象view 里面的GetDocument 函数的功能,
请问这样写会有什么潜在的缺陷么?
Cview *Cxxdoc::GetView(CRuntimeClass *pClass)
{
Cview* pview;
POSITION pos = GetFirstViewPosition();
while(pos!=NULL)
{
pview = GetNextView(pos);
if (!pview->IsKineOf(pClass));
break;
}
if (!pview->IsKineOf(pClass))
{
AfxMessageBox("Can Not Locate The VIew!");
}
}
请问这样写会有什么潜在的缺陷么?
Cview *Cxxdoc::GetView(CRuntimeClass *pClass)
{
Cview* pview;
POSITION pos = GetFirstViewPosition();
while(pos!=NULL)
{
pview = GetNextView(pos);
if (!pview->IsKineOf(pClass));
break;
}
if (!pview->IsKineOf(pClass))
{
AfxMessageBox("Can Not Locate The VIew!");
}
}
Cview *Cxxdoc::GetView(CRuntimeClass *pClass)
{
Cview* pview;
POSITION pos = GetFirstViewPosition();
while(pos!=NULL)
{
pview = GetNextView(pos);
if (!pview->IsKineOf(pClass));
break;
}
if (!pview->IsKineOf(pClass))
{
AfxMessageBox("Can Not Locate The VIew!");
return NULL;
}
return pview;
}
{
AfxMessageBox("Can Not Locate The VIew!");
return NULL;
}
还有,我感到奇怪,你的目的是“以取得象view 里面的GetDocument 函数的功能”
可是这个函数就在Document里,你干吗又去找呢?
“象view 里面的GetDocument 函数的功能”
那样在Document里面去做一个GetView()