I have implemented a generic list and I am trying to retrieve the data from a certain position in the list. umm… but I am getting an error: no matching function for call to ‘List::retrieve(int&, Record&)’
Below is the code of main.cpp and a snippet of function retrieve from List.h.#include
Main.cpp
#include <iostream>
#include "List.h"
#include "Key.h"
using namespace std;
typedef Key Record;
int main()
{
int n;
int p=3;
List<int> the_list;
Record data;
cout<<"Enter the number of records to be stored. "<<endl;
cin>>n;
for(int i=0;i<n;i=i++)
{
the_list.insert(i,i);
}
cout<<the_list.size();
the_list.retrieve(p, data);
cout<<"Record value: "<<data;
return 0;
}
List.h
Error_code retrieve(int position, List_entry &x)const
{
if(empty()) return underflow;
if(position<0 || position>count) return range_error;
x=entry[position];
return success;
}
For full code:
Main.cpp: http://pastebin.com/UrBPzPvi
List.h: http://pastebin.com/7tcbSuQu
P.S I am just learning the basics and the code may not be perfect with regards to large scale reusable module. At this stage, it just needs to work.
Thanks
data, which you are trying to pass as the second argument toretrieve, is of typeRecord.The second parameter of
retrieveis of typeList_entry, notRecord.When the compiler says “no matching function,” that usually means that it found a function with the name you used but one or more of the arguments that you are trying to pass to that function are of the wrong type or you are trying to pass the wrong number of arguments to the function.