注册 登录
编程论坛 VC++/MFC

求教:vs2008中list的使用,在vc++6.0中可以通过,在2008中编译不了

gengning938 发布于 2010-11-22 14:45, 1174 次点击
如题   list<unsigned int>::iterator itor_space;//定义itor_space;
   
       在使用初始化时编译不了
      CDisagreeDlg::CDisagreeDlg(CWnd* pParent /*=NULL*/)
    : CDialog(CDisagreeDlg::IDD, pParent)
{
    //{{AFX_DATA_INIT(CDisagreeDlg)
        // NOTE: the ClassWizard will add member initialization here
    //}}AFX_DATA_INIT
    m_pView = NULL;
    itor_1Lel =NULL;
    itor_space = NULL;//1这个位置出错,信息如下,#define NULL 0
 错误信息:
d:\booleanalign源码和驱动程序\booleanalign_6.1.7\booleanalign\disagreedlg.cpp(30) : error C2679: 二进制“=”: 没有找到接受“int”类型的右操作数的运算符(或没有可接受的转换)
        i:\program files\microsoft visual studio 9.0\vc\include\list(427): 可能是“std::list<_Ty>::_Iterator<_Secure_validation> &std::list<_Ty>::_Iterator<_Secure_validation>::operator =(const std::list<_Ty>::_Iterator<_Secure_validation> &)”
        with
        [
            _Ty=unsigned int,
            _Secure_validation=true
        ]
        试图匹配参数列表“(std::list<_Ty>::_Iterator<_Secure_validation>, int)”时
        with
        [
            _Ty=unsigned int,
            _Secure_validation=true
        ]
}
程序在VC6.0中可以编译,2008中过不去,请教高人如何解决?
1 回复
#2
玩出来的代码2010-11-22 20:02
你可根据错误提示打开相应的文件看看,在list文件中有这样的定义typedef _Iterator<_SECURE_VALIDATION_DEFAULT> iterator;而——Iterator又是一个模板类,看他的构造函数有个——Iterator(){}另外几个都是在条件编译下的不一定用到,所以在VC2008中提示没有相应的构造函数,
而在VC6中有这样的构造函数 iterator(_Nodeptr _P): const_iterator(_P) {}其中——Nodeptr是一个指针类型于是itor_space = NULL;会进行隐式类型转化而调用构造函数,
1