76 387
Assignments Done
Successfully Done
In May 2019

Answer to Question #39679 in C++ for Calvin Thames

Question #39679
Declare two classes: Class and Student. Add data members for the name, the grade (integer as 0-F, 1-D, 2-C, 3-B, and 4-A), and the credit hours to the class Class. Add all proper constructors (at least two) and accessor functions.

For the class Student, add the name (string) and Total Grade Points (integer). Overload operator + that will update the Total Grade points for the student (add the Class's grade to the total grade points)
Expert's answer
#include <iostream>
#include <string>
using namespace std;

class Class


Class(string x,int gr): m_Name(x), m_Grade(gr){}

Class(const Class& rhs): m_Name(rhs.m_Name), m_Grade(rhs.m_Grade) {}

virtual Class operator + (const Class& rhs)
Class b(m_Name + " and " + rhs.m_Name+" = ",m_Grade+rhs.m_Grade);
return b;

virtual void show()
cout << m_Name<<m_Grade << endl;


string m_Name;
int m_Grade;

class Student: public Class


Student(string x,int gr)
: Class(x,gr) {}

Student(const Student& rhs)
: Class(rhs.m_Name,rhs.m_Grade) {}

Student(const Class& rhs)
: Class(rhs) {}

operator Class()
return Class(m_Name,m_Grade);

Student operator + (const Student& rhs)
Student d = static_cast<Class>(*this) + static_cast<Class>(rhs);
return d;

void show()


int main()
Student d1("First",1), d2("Second",2), d3 = d1 + d2;
return 0;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions