CCreateContext *mCreateContext = NULL;
  mCreateContext->p_mNewViewClass = RUNTIME_CLASS(CView);  
  // 非法访问出现了,是不是CCreateContext结构中的指针变量地址不确定啊??
 

解决方案 »

  1.   

    不是p_mNewViewClass 是m_pNewViewClass
      

  2.   

    这样是可以的:
    CCreateContext mCreateContext;
    mCreateContext.m_pNewViewClass = RUNTIME_CLASS(CView);
    //与定义指针变量有什么区别啊
      

  3.   

    定义指针变量的时候,如果要使用这个变量,首先需要给这个指针变量申请一个对应的空间,你可以这样写:
    CCreateContext *mCreateContext = new CCreateContext;
    mCreateContext->m_pNewViewClass = xxx;记得在使用完mCreateContext之后释放该空间
    delete mCreateContext;