-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 이전에 다른 정렬 알고리즘을 수행했으나 제대로 작동했습니다. 이 프로토 타이핑 매치를 어떻게 수정할 수 있습니까?