だから私はこのコードに取り組んでいて、「バイナリ式 '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でそのような機能を知りません