Hey guys I am having issue with declaring an iterator of type vector. I know there are other errors within this file but I am more concerned with why these declarations arent working. Everyone gives me an error saying something along these lines for each iterator
heapsort.h:45: error: expected `;' before âitrâ
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;
template <class T>
void build_list(vector<T>&, const char*);
template <class T>
void print_list(const vector<T>&, int, int);
template <class T>
void sort_list(vector<T>&, Pred);
template <class T>
void build_list(vector<T>& itemList, const char* fileName)
{
ifstream inFile;
inFile.open(fileName);
if(inFile.fail())
{
cout << "input file did not open";
exit(0);
}
string item;
int i = 0;
while(inFile >> item)
{
itemList[i] = item;
i++;
}
inFile.close();
}
template <class T>
void print_list(const vector<T>& itemList, int itemWidth, int numPerLine)
{
vector<T>::const_iterator itr;
int x = 0;
for(itr = itemList.begin(); itr != itemList.end(); ++itr)
{
if(x <= numPerLine)
cout << left << setw(itemWidth) << *itr;
else
cout << endl << left << setw(itemWidth) << *itr;
x++;
}
}
template <class T, class Pred>
void sort_list(vector<T>& itemList, Pred predicate)
{
vector<T>::iterator itrStart;
vector<T>::iterator itrEnd;
priority_queue pq(itrStart, itrEnd, predicate);
}