Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a complete (yet brief) specification (student.h), implementation (student

ID: 3815254 • Letter: C

Question

Create a complete (yet brief) specification (student.h), implementation (student.cpp) and driver (studentDriver.cpp) files for a Student class. The class should store a last name (string) and ID number (int). Add a method isEqual() that takes a Student as an argument and returns true if the students have the same names and IDs, and false otherwise. Have the driver code use a default and a parameterized constructor and make a call to isEqual(). Your class needs to have getter and setter methods for each data member and an include guard. Use const appropriately.

Explanation / Answer

// Student.hpp

#include <string>

class Student

{

int student_id;

std::string name;

public:

Student();

Student(int id,std::string student_name);

~Student();

bool isEqual(Student other);

int getId();

std::string get_name();

void set_name(std::string student_name);

void set_id(int id);

};

//Student.cpp

#include "Student.hpp"
#include <iostream>
using namespace std;
Student::Student(int id,std::string student_name){
   cout<<"Parameterised constructor invoked"<<endl;
   student_id = id;
   name = student_name;
}
Student::Student(){
   cout<<"Default constructor invoked"<<endl;
}
Student::~Student(){
   cout<<"Destructor invoked"<<endl;
}
int Student::getId() {
   return student_id;
}

bool Student::isEqual(Student other){
   return ( other.getId() == student_id);
}

void Student::set_name(std::string student_name){
   name = student_name;
}
void Student::set_id(int id){
   student_id = id;
}

std::string Student::get_name(){
   return name;
}

//StudentDriver.cpp

#include "Student.cpp"
int main(int argc, char const *argv[])
{  
   string name = "a name";
   Student a(1,name);
   Student b;
   name = "b name";
   b.set_name(name);
   b.set_id(2);
   if(a.isEqual(b)){
       cout<<"They are equal"<<endl;
   }else{
       cout<<"Not equal"<<endl;
   }
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote