vector <st_Char*> m_pCharArray;//数据类型
//-------------------vector <st_Char *>::iterator it;
it = &m_pCharArray[nPos];//这句出错,npos是整形
//
Error 26 error C2679: binary '=' : no operator found which takes a right-hand operand of type 'st_Char **__w64 ' (or there is no acceptable conversion) d:\EditCtrlSrc\EditCtrl.cpp 167 m_pCharArray.erase(&m_pCharArray[nPos]);//这句出错,npos是整形Error 27 error C2664: 'std::_Vector_iterator<_Ty,_Alloc> std::vector<_Ty>::erase(std::_Vector_iterator<_Ty,_Alloc>)' : cannot convert parameter 1 from 'st_Char **__w64 ' to 'std::_Vector_iterator<_Ty,_Alloc>' d:\EditCtrlSrc\EditCtrl.cpp 193 我的编译器是VS2005,请问如何修改,是数据类型转换问题吗?
困惑了,头文件我已经包括<VECTOR> STD 名字空间也声明了.

解决方案 »

  1.   

    struct st_Char
    {
    bool bI;
    char szChar[3];
    };忘了说明数据结构了.这是st_Char的类型结构.高手帮忙分析一下为什么编译出错
      

  2.   

    为什么用这样访问呢?
    it = m_pCharArray.begin();
    it++;要读数据的时候,*it就可以了
      

  3.   

    struct st_Char
    {
    bool bI;
    char szChar[3];
    };
    vector <st_Char*> m_pCharArray;
    vector <st_Char *>::iterator it;
    it = &m_pCharArray[nPos];//
    m_pCharArray.erase(&m_pCharArray[nPos]);//我需要这两条赋值,各位帮帮忙吧
      

  4.   

    可以换一个方法(不过不是很好)
    vector <st_Char *>::iterator it;
    it = m_pCharArray.begin()//vector是你定义的vector名称
    for( ; it != vector.end();it++ )
    {
      if( it->** = m_pCharArray[nPos] )
    找到;
       break;
    else if( it == m_pCharArray.end()-1 )
    没有找到;}if( 找到 )
    m_pCharArray.erase(it );比较笨的方法,不过可以实现你所要的功能.如果你找到了好的方法,不防共享一下
      

  5.   

    it = &m_pCharArray[nPos];//这句出错,npos是整形回答如下:
    it 的类型为vector <st_Char *>::iterator 
    而 &m_pCharArray[nPos];为指针.
    是不可能用" = "的