那有啥啊,你定义一个类包含一个CString,别的类就不允许包含CString了?

解决方案 »

  1.   

    是说m_pMainWnd是一个类型为CWnd*的PUBLIC属性的变量(CWinThread的成员变量)
      

  2.   

    是说m_pMainWnd指针是CWinThread类的一个成员变量,这个
    成员变量是指向CWnd类对象的指针。
    CWinThread::m_pMainWnd 说明m_pMainWnd的作用域,而
    m_pMainWnd is a public variable of type CWnd* 则说明类型,
    不矛盾!
      

  3.   

    对,我要给你们加分,还想问个问题:
    我是初手,
    我写了一段简单的代码,运行是正确的,
    如下:
            CWnd* wnd,* view;
    wnd=AfxGetMainWnd();
            view=((CMainFrame*)wnd)->GetActiveView();
            view->PostMessage(WM_MSG1,0,0);
    但我查了MSDN,GetActiveView()返回CView*,但我的view
    是CWnd*的,还有强制转换在什么了条件下才可以用,不同的
    指针之间都可以无条件转换吗,上面代码有一个转换(CMainFrame*)wnd
      

  4.   

    强制转换在什么了条件下才可以用?
          : when you want to use
       but you must kown the type of the memory pointed by the pointerm , kown yourelf not computer.
       you can up cast a pointer.
                    CWnd* pWnd =  pView;
       but when down cast a pointer
       your code must be :
                  CView* pView = (CView*) pWnd;
      and you must be sure the  pWnd point to an instence of CView or any Class
      which parent class is CView.
      
      
       
      

  5.   

    因为他本来就是指向CMainFrame的指针,所以可以强制转换
    指向基类的指针也可以指向他的派生类,所以CWnd*也可以指向CView
    事实上CView*也是CWnd*