声明一个vector<Encoder> *m_pvecBothEncoder;
怎样判断m_pvecBothEncoder为空》??????

解决方案 »

  1.   

    vector<Encoder> *m_pvecBothEncoder = NULL;
    //...if(m_pvecBothEncoder == NULL ) 
    //...
      

  2.   

    判断没有成员?
    m_pvecBothEncoder->size() == 0
      

  3.   

    Tests if the vector is empty.
    bool empty( ) const;
     
      

  4.   


    if ( m_pvecBothEncoder != NULL )
    {
    m_pvecBothEncoder->clear();
    }
    提示
    Unhandled exception at 0x0051e364 in iScanTVClient.exe: 0xC0000005: Access violation reading location 0xcdcdcdd9.
      

  5.   


    if ( m_pvecBothEncoder != NULL )
    {
    m_pvecBothEncoder->clear();
    }
    提示
    Unhandled exception at 0x0051e364 in iScanTVClient.exe: 0xC0000005: Access violation reading location 0xcdcdcdd9.
      

  6.   

    建议楼主看下C++primer。指针木有初始化,也木有分配空间
      

  7.   

    一般这样声明 :vector<Encoder> vecBothEncoder;vector<Encoder>::iterator m_pvecBothEncoder=vecBothEncoder.begin();
      

  8.   

    vector<Encoder> *m_pvecBothEncoder
    bool beEmpty = ( *m_pvecBothEncoder ).empty();
    if ( beEmpty )
    {
      MessageBoxA( NULL , "It 's Empty " , "Qt" , MB_OK|MB_TOPMOST );
    }
    else
    {
      MessageBoxA( NULL , "It 's Not Empty " , "Qt" , MB_OK|MB_TOPMOST );
    }
      

  9.   

    LZ的定义有问题吧,应该是下面的:
    vector<Encoder> *m_pvecBothEncoder  --》》 vector<Encoder*> m_pvecBothEncoder