Hello. I am fairly new to C++. I am writing a program using chain hashing. My program begins to compile, but then errors out. I cannot seem to figure out where it is going wrong. Here is the table2.template file that I am writing.
// FILE: tableTest.cxx
#include <iostream>
#include <fstream>
#include <string>
#include "table2.h"
usingnamespace main_savitch_12B;
usingnamespace std;
struct TableRecord
{
int key;
double data;
};
constint MAX_KEY = 5000;
constint TABLE_SIZE = 811;
int main(int argc, char *argv[])
{
cout << "*************************************";
cout << "\nCSC-161 Homework Eleven Solution\n";
cout << "*************************************";
table<TableRecord> testTable;
TableRecord testRecord;
for (int index = 0; index < 100; index++)
{
testRecord.data = (double)index * 50;
testRecord.key = index * 50;
testTable.insert(testRecord);
}
testRecord.data = 99.0;
testRecord.key = 300;
testTable.insert(testRecord);
testRecord.data = 99.0;
testRecord.key = TABLE_SIZE;
testTable.insert(testRecord);
testRecord.data = 99.0;
testRecord.key = TABLE_SIZE * 2;
testTable.insert(testRecord);
testRecord.data = 99.0;
testRecord.key = TABLE_SIZE * 10;
testTable.insert(testRecord);
cout << "\nAdded " << testTable.size() << " records to the test table" << endl;
cout << "*************************************";
testTable.remove(100);
testTable.remove(150);
testTable.remove(1500);
testTable.remove(250);
testTable.remove(250);
testTable.remove(3750);
testTable.remove(4900);
testTable.remove(TABLE_SIZE * 2);
testTable.remove(TABLE_SIZE);
cout << "\nAfter removals there are " << testTable.size() << " records in the test table" << endl;
cout << "*************************************";
cout << "\nTry some searches for key values\n";
bool found = false;
for (int index = 0; index < MAX_KEY; index = index + 150)
{
testTable.find(index, found, testRecord);
if (found)
cout << "Found record with key value " << index << ", data = " << testRecord.data << endl;
else
cout << "Did not find record with key value " << index << endl;
}
if (testTable.is_present(TABLE_SIZE * 10))
cout << "\nSuccessfully found record with key equal to " << TABLE_SIZE * 10 << endl;
else
cout << "\n?? Failed to find record with key equal to " << TABLE_SIZE * 10 << endl;
cout << "*************************************" << endl;
cout << "End of Homework Eleven Solution" << endl;
cout << "*************************************" << endl;
system("Pause");
}
There is also a node header and template file that i did not include. The last line in the test file that processes is line 69 "cout << "\nTry some searches for key values\n";" Any help on this issue would be greatly appreciated! Thanks :)