2011-02-09 91 views
0
class RC5 { 
     public: 
     RC5() : 
      _bufKey(new unsigned __int32[4]), 
      _bufSub(new unsigned __int32[26]) { 
     } 
     unsigned __int8 Test(unsigned __int8 data); 

     virtual ~RC5() { 
      delete [] _bufKey; 
      delete [] _bufSub; 
     } 
     private: 
     unsigned __int32 *const _bufKey; 
     unsigned __int32 *const _bufSub; 
    }; 

    unsigned __int8 RC5::Test(unsigned __int8 data) 
    { 
       for (int i = 0; i < 4; i++) 
       { 
        _bufKey[i] = (unsigned __int32)(data[i * 4] + (data[i * 4 + 1] << 8) + (data[i * 4 + 2] << 16) + (data[i * 4 + 3] << 24)); 
        }  
    } 

我得到这个错误:表达式必须具有指针到的对象类型,下标要求数组或指针类型表达式必须有指针到的对象类型,下标要求数组或指针类型

+0

为什么不使用`std :: vector`? – GManNickG 2011-02-09 10:36:12

+0

@GMan因为接受的答案[在另一个问题](http://stackoverflow.com/q/4942984/1968)建议这个。 – 2011-02-09 11:05:06

回答

1

它看起来像问题是在你的测试函数中,你传递的数据是一个无符号的__int8而不是这些值的数组。带方括号的下标是导致错误的原因。更改函数以通过数组取值应该可以解决这个问题。

相关问题