所以我正在处理这段代码,我收到一个错误“二进制表达式'int'到'int *'的无效操作数”我将向您展示我尝试过的测试方法以及我正在尝试的工作这给了我一个错误。
//assume aptr has been declared in a base class
template<class T>
void SortableVector<T>::sortDescending() {
for(int x = 0; x < this->arraySize; x++)
cout << *(this->aptr + x) << ' '; // this line works just fine.
//everything beyond this line does not work
for ( int i = 0; i < this->arraySize; i++)
{
for (int j = i+1; j < this->arraySize; j++)
{
if ( *(this->aptr + i) < *(this->aptr + j))
{
int temporary = *(this->aptr+i);
*(this->aptr + i) = *(this->aptr + j)
*(this->aptr + j) = temporary; // here is where the errors appear
// also, it doesn't appear anywhere else
// e.g. on the line above it.
}
}
}
}
拜托,如果有人能告诉我我是否在这里遗漏了什么,我将不胜感激。我正在尝试在 Xcode 中执行此操作,我会尝试“强制运行”它,但我不知道该怎么做,也不知道 Xcode 中的类似功能