template

Can someone tell me why I am getting an error of no matching function for call to 'Bubble(int&)'? Thank you!

#include<iostream>
#include<iomanip>
#include<math.h>
#include<cstdlib>
#include<ctime>
#include<fstream>
const int N=10;

using namespace std;

template <class type>

void Bubble(type ta[])
{
double asci;
//ofstream outfile("TriBubble.txt");
{
for(int p=0; p<N; p++)
{
ta[p]=rand()%N;
asci=(int)ta[p];
cout<<ta[p]<<","<<asci<<",";
}
}
//outfile.close();
}

template <class type>

void sort (type ta[])
{
for(int d=0; d<10; d++)
{
for(int a=0; a<N; a++)
{
if (ta[a]>ta[a+1])
{
swap(ta[a],ta[a+1]);
}
}
}

}
void swap (int &a, int &b)
{
int temp;
temp=a;
a=b;
b= temp;
}

int main()
{
int a,b;
int intarray;
//char chararray;
//double doublearray;
Bubble(intarray);
//Bubble(chararray);
//Bubble(doublearray,tg);
swap(a,b);
//sort(intarray);
}
Last edited on
"int intarray;" declares a single integer, not an array. And, as the compiler rightfully points out, you didn't declare a Bubble() that takes a single integer.
bubble function expects an array
I put an brackets in the main "int intarray[N]" and took them out of the "void Bubble(type &ta)". Could someone explain why that worked and why I had to declare it in the main and I couldn't have just put it in the parameters of Bubble like I have done on other programs.
Topic archived. No new replies allowed.