Iurii Tatishchev 30ad8892de
9.14 Lab: Hash ADT
Now that you have a working implementation of the HashNode and HashTable classes, you can convert them to templates, and update main.cpp to match with the new template classes.

In order for everything to work you will also have to:

- overload the == operator for the Student class
- declare the hash function a friend function of the Student class
- send the hash function as an argument to insert, remove, and search functions.
2024-05-11 16:44:34 -07:00

47 lines
945 B
C++

// Specification file for the Student class
// Modified by: Iurii Tatishchev
// IDE: CLion
#ifndef STUDENT_H
#define STUDENT_H
using std::string;
class Student; // Forward Declaration
// Function Prototypes for friend functions
int key_to_index(const Student &key, int size);
class Student {
private:
double gpa;
string name;
public:
Student() {
name = "";
gpa = -1;
} // Constructor
Student(string n, double g) {
name = n;/* Write your code here */
gpa = g;
} // Overloaded Constructor
// Setters and getters
void setName(string n) { name = n; }
void setGpa(double g) { gpa = g; }
string getName() const { return name; }
double getGpa() const { return gpa; }
// Overloaded operators
bool operator==(const Student& other) { return name == other.name; }
// friend functions
friend int key_to_index(const Student& key, int size);
};
#endif