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

Computer Science C++ Programming Problem. I want to Code for Student.h and Stude

ID: 3700120 • Letter: C

Question

Computer Science C++ Programming Problem.

I want to Code for Student.h and Student.cpp files.

14. (12 points) Given the following UML diagram, write an interface (in the header file) and implementation (in the corresponding source code file) for this Student class. Be sure to include all neccssary for code for the declaration and definitions of the member attributes and methods. In overloading the operator for this class, consider two Students cqual if their names are equivalent Student Name: String -ID: Number Email: String +Student(Name, ID, Email) +set name(Name) +get_name0: String operator-(Student): Boolean nterface (Student.h) Implementation (Student.opp)

Explanation / Answer

// File Name: Student.h

// Specification file for the Student class
#ifndef STUDENT
#define STUDENT
#include<string>
using namespace std;

// Class Student definition
class Student
{
private:
// Private data member to store data
string Name;
int ID;
string Email;

public:
// Prototype of member function
Student(string, int, string);
void set_name(string);
string get_name();
bool operator ==(Student);
};// End of class

#endif

--------------------------------------------------------------------

// File Name: Student.cpp
#include "Student1.h"
#include<iostream>
#include<string>
using namespace std;

// Parameterized constructor to initialize data member
Student::Student(string Name, int ID, string Email)
{
// Though data member and parameter variable name is same in order to distinguish them this is used before the data member
// this refers to data member.
this->Name = Name;
this->ID = ID;
this->Email = Email;
}// End of constructor

// Function to set name
void Student::set_name(string Name)
{
this -> Name = Name;
}// End of function

// Function to return name
string Student::get_name()
{
return Name;
}// End of function

// Overloading == operator using member function
// Function to return if two object name is same otherwise false
bool Student::operator ==(Student st)
{
// this refers to current object
// The object which is calling this function is implicitly available with this pointer
// Checks the name of st object and the current object name
// if same return true
if(st.get_name() == this->get_name())
return true;
// Otherwise return false
else
return false;
}// End of function

// main function definition
int main()
{
// Creates three objects using parameterized constructor
Student s1("Pyari", 111, "pms@gamil.com");
Student s2("Pyari", 222, "pyari@gamil.com");
Student s3("Mohan", 333, "mohan@gamil.com");

// Checks the object s1 equals to s2 using == operator overloading
if(s1 == s2)
cout<<" Student1 "<<s1.get_name()<<" Student2 "<<s2.get_name()<<" Both the students are same.";
else
cout<<" Student1 "<<s1.get_name()<<" Student2 "<<s2.get_name()<<" Both the students are not same.";
// Checks the object s1 equals to s3 using == operator overloading
if(s1 == s3)
cout<<" Student1 "<<s1.get_name()<<" Student3 "<<s3.get_name()<<" Both the students are same.";
else
cout<<" Student1 "<<s1.get_name()<<" Student3 "<<s3.get_name()<<" Both the students are not same.";
}// End of main function

Sample Output:

Student1 Pyari
Student2 Pyari
Both the students are same.
Student1 Pyari
Student3 Mohan
Both the students are not same.

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