2013-12-09
展开全部
通过函数 CView::CDocument::GetNextView(POSITION& rPosition)获得了一个视图指针,或者通过其他方式获得的,但文档包含了多个视图时,用下面的方法判断该指针是哪一个视图类:【方法】
调用IsKindOf()【代码】
CView* pView;
if(pView->IsKindOf(RUNTIME_CLASS(CMyView)))
{
//是的
}
else
{
//不是的
}
调用IsKindOf()【代码】
CView* pView;
if(pView->IsKindOf(RUNTIME_CLASS(CMyView)))
{
//是的
}
else
{
//不是的
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-12-09
展开全部
用RTTIclass Base {
public:
virtual void vvfunc() {}
};
class Derived : public Base {};
int main()
{
Derived* pd = new Derived;
Base* pb = pd;
cout << typeid( pb ).name() << endl; //prints "class Base *"
cout << typeid( *pb ).name() << endl; //prints "class Derived"
cout << typeid( pd ).name() << endl; //prints "class Derived *"
cout << typeid( *pd ).name() << endl; //prints "class Derived"
delete pd;
}
public:
virtual void vvfunc() {}
};
class Derived : public Base {};
int main()
{
Derived* pd = new Derived;
Base* pb = pd;
cout << typeid( pb ).name() << endl; //prints "class Base *"
cout << typeid( *pb ).name() << endl; //prints "class Derived"
cout << typeid( pd ).name() << endl; //prints "class Derived *"
cout << typeid( *pd ).name() << endl; //prints "class Derived"
delete pd;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询