ユーザーが入力した等級の数。私はダイナミックな配列の割り当てに取り組んでいます。私は自分のコードに自信がありますが、Xcodeは私のソート機能にエラーを与えています。私はそれを正しくやっていると思っていましたが、明らかに何かが間違っています。私はまだ動的メモリ割り当てを把握しようとしています。だから私のエラーはどこから生成されているのでしょうか、私は原因がどこにあるのか分かりません。ここに私のフルプログラムがあります:Xcodeのエラー:オーバーロードされた関数への参照を参照できませんでした
// This program demonstrates the use of dynamic arrays
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
//Function Prototypes
void sort(float *score[], int numOfScores);
int main()
{
float *scores;
int total = 0;
float average;
float numOfScores;
int count;
cout << fixed << showpoint << setprecision(2);
cout << "Enter the number of scores to be averaged and sorted.";
cin >> numOfScores;
scores = new float(numOfScores);
for (count = 0; count < numOfScores; count++)
{
cout << "Please enter a score:" << endl;
cin >> scores[count]; }
for (count = 0; count < numOfScores; count++)
{
total = total + scores[count];
}
average = total/numOfScores;
cout << "The average score is " << average << endl;
sort(*scores, numOfScores);
delete [] scores;
return 0;
}
//*******************************************
// Sort Function
// Bubble sort is used to sort the scores
//*******************************************
void sort(float *score[], int numOfScores)
{
do
{
bool swap = false;
for (int count = 0; count < (numOfScores -1); count++)
{
if (*score[count] > *score[count+1])
{
float *temp = score[count];
score[count] = score[count+1];
score[count+1] = temp;
swap = true;
}
}
}while(swap); //This is where I'm receiving the error.
}
ありがとう!
'スコア=新しいフロート(numOfScores);'私は真剣に疑いあなたはそれがないと思う何をしても、その。あなたが 'scores = new float [numOfScores];'を望んでいることを確かめてください。そして、 'float * score []'はあなたのパラメータの型には間違いありません。あなたは 'float score []'が必要です。 – WhozCraig
[条件でdo-whileループ内で宣言された変数を使用する](http://stackoverflow.com/questions/18541304/use-variables-declared-inside-do-while-loop-in-the-condition) – LogicStuff
そのエラーメッセージが修正されましたが、現在は「アルゴリズム」に関するエラーメッセージが表示されます。私も '#include'を取り出してみましたが、まだエラーメッセージが出ます。何か案は? –