-1

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

4

2 に答える 2

1

の最後にa を忘れました;:

*(this->aptr + i) = *(this->aptr + j)

(エラー行の前の行)

于 2013-07-14T01:25:11.573 に答える
1

ここにセミコロンがありません:

*(this->aptr + i) = *(this->aptr + j)
于 2013-07-14T01:27:00.523 に答える