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 :(得分:1)
看起来问题在于,在Test函数中,您将数据作为无符号__int8而不是作为这些值的数组传递。下标方括号是导致错误的原因。更改函数以通过数组获取它的值应解决此问题。