Working on a group project, our group has not been able to use our custom HashTable class inside a Windows form (using Visual Studio 2010). Below is all the (hopefully) relevant code. The errors we get when trying to compile this are:
error C2059: syntax error : 'constant' (LINE 42)
error C2227: left of '->insert' must point to class/struct/union/generic type (LINE 48)
#include "hashTable.h"
namespace studentHashExample {
usingnamespace System;
usingnamespace System::ComponentModel;
usingnamespace System::Collections;
usingnamespace System::Windows::Forms;
usingnamespace System::Data;
usingnamespace System::Drawing;
/// <summary>
/// Summary for Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ clearButton;
private: System::Windows::Forms::Button^ insertButton;
private: System::Windows::Forms::Button^ searchButton;
HashTable myTable(19);
/* rest of form controls and auto-generated code snipped */
private: System::Void insertButton_Click(System::Object^ sender, System::EventArgs^ e) { //insert button event
StudentProfile myProfile;
int::TryParse(studentIDTextBox->Lines[0],myProfile.idNumber);
myTable->insert(myProfile);
}
/* other form event functions snipped */
hashTable.h:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <vector>
#include "StudentProfile.h" // StudentProfile struct defined here
class HashTable
{
private:
int size;
vector<StudentProfile> table;
public:
HashTable(int size);
bool insert(StudentProfile newProfile);
bool remove(int IDnum)
void clear();
bool search(int IDnum);
//void display(int caseNum);
}
Could anyone shed some insight as to how to make our HashTable object be recognized and used by the GUI form? We've devolved to pasting the HashTable declaration in every possible spot. There is some deeper problem that we're not seeing.