Z
zfareed
int main()
{
ifstream inFile;
ifstream inFile2;
int x,y=0;
float z;
int number;
bool found;
SortedList<int> Aint;
SortedList<float> Bfloat;
SortedList<ItemType> C;
/* Read in data from two data files
one is a list of integers to be inserted into int SortedList
and the other a list of float to be inserted into float SortedList
*/
inFile.open("int.dat");
cout << "The number of elements in the first file: ";
cout << numIntElement(inFile,j)<< endl;
cout << endl;
inFile.close();
inFile.open("int.dat");
inFile2.open("float.dat");
cout << "The number of elements in the second file: ";
cout << numFloatElement(inFile2,y)<< endl;
cout << endl;
inFile2.close();
inFile2.open("int.dat");
for(int t=0;t<y;t++)
{
inFile2 >> z;
Bfloat.InsertItem(z);
}
Bfloat.ResetList();
for(int s=0;s<y;s++)
{
Bfloat.RetrieveItem(a,found); // the errors are here
/*Bfloat.GetNextItem();*/ //
}
I am tryimg to call a function of a class template in the main
program. the instance Bfloat is calling the RetrieveItem method to
find a value in a float list.
ERROR:
templatedriver.cpp no matching function for call to
`SortedList<float>::RetrieveItem(ItemType&, bool&)'
candidates are: void SortedList<ItemType>::RetrieveItem(ItemType&,
bool&) const [with ItemType = float]
The function name is below.
template<class ItemType>
void SortedList<ItemType>::RetrieveItem(ItemType &a,bool &found) const
{
I had no errors with the InsertItem function. Can anyone help please?
{
ifstream inFile;
ifstream inFile2;
int x,y=0;
float z;
int number;
bool found;
SortedList<int> Aint;
SortedList<float> Bfloat;
SortedList<ItemType> C;
/* Read in data from two data files
one is a list of integers to be inserted into int SortedList
and the other a list of float to be inserted into float SortedList
*/
inFile.open("int.dat");
cout << "The number of elements in the first file: ";
cout << numIntElement(inFile,j)<< endl;
cout << endl;
inFile.close();
inFile.open("int.dat");
inFile2.open("float.dat");
cout << "The number of elements in the second file: ";
cout << numFloatElement(inFile2,y)<< endl;
cout << endl;
inFile2.close();
inFile2.open("int.dat");
for(int t=0;t<y;t++)
{
inFile2 >> z;
Bfloat.InsertItem(z);
}
Bfloat.ResetList();
for(int s=0;s<y;s++)
{
Bfloat.RetrieveItem(a,found); // the errors are here
/*Bfloat.GetNextItem();*/ //
}
I am tryimg to call a function of a class template in the main
program. the instance Bfloat is calling the RetrieveItem method to
find a value in a float list.
ERROR:
templatedriver.cpp no matching function for call to
`SortedList<float>::RetrieveItem(ItemType&, bool&)'
candidates are: void SortedList<ItemType>::RetrieveItem(ItemType&,
bool&) const [with ItemType = float]
The function name is below.
template<class ItemType>
void SortedList<ItemType>::RetrieveItem(ItemType &a,bool &found) const
{
I had no errors with the InsertItem function. Can anyone help please?