-1
NetBeansでこれを実行する際に問題が発生しました。 ここでは主な機能など、バブルソートアルゴリズムのための私のクラスである:エラープロトタイプがクラス内で一致しません
#include <iostream>
using namespace std;
template <class elemType>
class arrayListType
{
public:
void BubbleSort();
private:
elemType list[100];
int length;
void swap(int first, int second);
void BubbleUp(int startIndex, int endIndex);
void print();
void insert();
};
template <class elemType>
void arrayListType<elemType>::BubbleUp(int startIndex, int endIndex)
{
for (int index = startIndex; index < endIndex ; index++){
if(list[index] > list[index+1])
swap(index,index+1);
}
}
template <class elemType>
void arrayListType<elemType>::swap(int first, int second)
{
elemType temp;
temp = list[first];
list[first] = list[second];
list[second] = temp;
}
template <class elemType>
void arrayListType<elemType>::insert()
{
cout<<"please type in the length: ";
cin>>length;
cout<<"please enter "<<length<<" numbers"<< endl;
for(int i=0; i<length; i++)
{
cin>>list[i];
}
}
template <class elemType>
void arrayListType<elemType>::print()
{
cout<<"the sorted numbers" << endl;
for(int i = 0; i<length; i++)
{
cout<<list[i]<<endl;
}
}
エラーは、この関数の宣言で表されます。
template <class elemType>
void arrayListType<elemType>::BubbleSort(elemType list[], int numvalues)
{
insert();
int current=0;
numvalues--;
while(current < numvalues)
{
BubbleUp(current,numvalues);
numvalues--;
}
print();
}
主な機能:
int main()
{
arrayListType<int> list ;
list.BubbleSort();
}
I前に別のソートアルゴリズムを実行しましたが、うまくいきました。このプロトタイピングマッチをどうすれば修正できますか?