Je suis confronté à un problème lors de l'exécution de ceci sur NetBeans. Voici ma classe pour un algorithme de tri à bulles dont la fonction principale:Le prototype d'erreur ne correspond à aucun dans la classe
#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;
}
}
L'erreur est représentée dans cette déclaration de fonction:
template <class elemType>
void arrayListType<elemType>::BubbleSort(elemType list[], int numvalues)
{
insert();
int current=0;
numvalues--;
while(current < numvalues)
{
BubbleUp(current,numvalues);
numvalues--;
}
print();
}
la fonction principale:
int main()
{
arrayListType<int> list ;
list.BubbleSort();
}
I a fait un autre algorithme de tri avant, mais cela a bien fonctionné. Comment puis-je vraiment résoudre ce problème de prototypage?