我定义了一个文档类,在视图中引用,
void CNewFarmerView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
CFarmerDoc *pDoc=GetDocument();
pDoc->InitData();
m_edtCardNum.SetWindowText("ksdjfkl"); // pDoc->m_longCardNum;
// return TRUE;
}但是编译是发生如下错误,我的CFarmerDco是继承CDocument的类。请高手给一个解决方法。
E:\Farmprj\NewFarmerView.cpp(96) : error C2440: 'initializing' : cannot convert from 'class CDocument *' to 'class CFarmerDoc *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
void CNewFarmerView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
CFarmerDoc *pDoc=GetDocument();
pDoc->InitData();
m_edtCardNum.SetWindowText("ksdjfkl"); // pDoc->m_longCardNum;
// return TRUE;
}但是编译是发生如下错误,我的CFarmerDco是继承CDocument的类。请高手给一个解决方法。
E:\Farmprj\NewFarmerView.cpp(96) : error C2440: 'initializing' : cannot convert from 'class CDocument *' to 'class CFarmerDoc *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
pDoc->InitData();
又发生了错误,好象是系统的
因为你的GetDocument()的返回值是指向CDocument的,所以要强制转换一下!
这在许多地方都要引起注意