在头文件中定义了一个模板类
typedef CTypedPtrList<CObList, CStudent*> CStudentList;
然后在程序中定义
CStudentList m_stuentList;
以及
CStudentList* GetList() 
{  return &m_studentList; }程序中还有
m_studentList.GetHeadPosition()编译的时候这两个地方出错
出错信息为:
 error C2065: 'm_studentList' : undeclared identifier
 error C2065: 'm_studentList' : undeclared identifier
 error C2228: left of '.GetHeadPosition' must have class/struct/union type
 fatal error C1903: unable to recover from previous error(s); 
  stopping compilation请问是不是少了什么??
应该代码没有问题呀???
(已经在StdAfx.h中加入#include<afxtempl.h>)

解决方案 »

  1.   

    typedef CTypedPtrList<CObList, CStudent*> CStudentList;你是定义了一个template class的类型叫CStudentList,而不是申明了一个变量。(注意typedef)是否应该去掉typedef,改为:
    CTypedPtrList<CObList, CStudent*> CStudentList;
      

  2.   

    'm_studentList'  这个定义有问题!
    1:看看拼写对马?
    2:看看你的定义对马?
    .....
      

  3.   

    对不起
    上面说得对,拼写错了继续提问:
    已经定义过了
    CStudentList * m_pList
    然后在程序中使用
    m_pList=GetDocument()->GetList;编译出错信息为:
    error C2440: '=' : cannot convert from 'class CTypedPtrList<class CObList,class CStudent *> *(__thiscall CStuDoc::*)(void)' to 'class CTypedPtrList<class CObList,class CStudent *> *'
            There is no context in which this conversion is possible这是什么意思????
      

  4.   

    大哥,GetList是函数,要加括号的。