Question
In C++ write a class. The requirements for the class are define as followings: Using the Student and StudentHash class below create a StudentHashDriver class
In C++ write a class. The requirements for the class are define as followings:
Using the Student and StudentHash class below create a StudentHashDriver class
#include
using namespace std; class student { public: string first_name; string last_name; string middle_name; int Student_ID; student() { cout<<"Enter first name="; cin>>first_name; cout<<"Enter last name="; cin>>last_name; cout<<"Enter ID="; cin>>Student_ID; cout<<"Do you have Middle name(0 for no, 1 for yes)"; int n; cin>>n; if(n) { cout<<"Enter Middle name="; cin>>middle_name; } } };
class StudentHash {
public: StudentHash(int n) { students = new Student*[n]; size = n; }
void add(Student *s) { int index = s->Student_ID % size; if(students[index] == NULL) { students[index] = s; return index; } else { return -1 * index; } }
Student* search(int id) { int index = id % size;
if(students[index] != NULL && s->Student_ID == id) { return students[index]; } else { return NULL; } }
void printRecords() { for(int i=0; i private: student **students; int size; };
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started