I'm making a header file to make, sort, and print a vector using heapsort. I keep getting a compiler error about my const char[100] array. Probably something really simple I'm missing...I hope.
In function `void build_list(std::vector<T, std::allocator<_CharT> >&, const char*)':
16 expected primary-expression before "const"
16 expected `;' before "const"
#ifndef HEAPSORT_H
#define HEAPSORT_H
#include <iostream>
#include <vector>
#include <fstream>
#include <cstring>
#include <iomanip>
#include <algorithm>
using namespace std;
template <class T>
void build_list(vector<T>& itemList, const char* fileName)
{
const char[100] file = fileName;
ifstream inFile;
inFile.open("file");
if(!inFile)
{
cout << "input file did not open";
cin.get();
exit(0);
}
T item;
while(inFile >> item)
{
itemList.push_back(item);
}
inFile.close();
}
template <class T>
void print_list(const vector<T>& itemList, int itemWidth, int numPerLine)
{
int counter = 0;
//for(int i = itemList.begin(); i != itemList.end(); ++i)
for(int i = 0; i != itemList.size(); ++i)
{
cout << setw(itemWidth) << itemList.at(i);
if(counter == numPerLine)
{
cout << endl;
counter = 0;
}
counter++;
}
}
template <class T, class Pred>
void sort_list(vector<T>& itemList, Pred predicate)
{
sort_heap(itemList.begin(), itemList.end());
}
#endif