Question: // Code given #include #include #include using namespace std; // parent or base class class SCUMember { public: SCUMember(const string& name, const string& email, const
// Code given
#include
#include
#include
using namespace std;
// parent or base class
class SCUMember {
public:
SCUMember(const string& name, const string& email, const string& addr);
void change_address(const string& new_address);
string to_string() const; // for printing
private:
string name_;
string email_;
string addr_;
};
// ===========
// derived class - Student
class Student : public SCUMember {
public:
Student(const string& name, const string& email, const string& addr, const string& major);
void change_major(const string& new_major);
string to_string() const;
private:
string major_;
};
//==============
// defining SCUMember
SCUMember::SCUMember(const string& name, const string& email,
const string& addr) : name_(name), email_(email), addr_(addr) { }
void SCUMember::change_address(const string& new_address) {
addr_ = new_address;
}
string SCUMember::to_string() const {
return "SCU Member =: " + name_ + " , " + email_ + " , " + addr_;
}
// defining Student
Student::Student(const string& name, const string& email,
const string& addr, const string& major) : SCUMember(name, email, addr), major_(major) { }
void Student::change_major(const string& new_major) {
major_ = new_major;
}
string Student::to_string() const {
return SCUMember::to_string() + " Student's major =: " + major_;
}
// ==================
// driver code
int main() {
SCUMember sm("sukanya", "smanna@scu.edu", "OCB");
/*
cout
sm.change_address("Lucas");
cout
iv. V. Problem statements: 3. Using w5_inheritance.cpp uploaded in Camino under week 5 module. Make the following changes to the code. a. (3 points) Split the file into the following multiple files: i. SCUMembers.h ii. SCUMembers.cpp iii. Student.h Student.cpp main.cpp (to test your code) b. (15 points) Now derive another class Staff.h and Staff.cpp from SCUMember: such that the new class will have two member variable int level and std::string department_along with the following methods: i. Add a suitable constructor to set initial level_and department_. Make sure all the members of the base class are also correctly initialized. ii. void change_level(const int new_level) which will be changed only if new_level is greater than existing level they get a promotion iii. void std::switch_dept(const std::string& new_dept) - will be used if they get transferred to another department iv. std::string to_string() - to print the member information including SCUMember details as well as department level. Try to use SCUMember::to_string() to print SCUMember details. Also add the necessary getter methods for the other class SCUMember and Student in the sample code provided. C. (2 points) You have to complete the existing main.cpp, so that 1. You will instantiate objects of each of the classes, SCUMember Student, and Staff. Test all the methods present in each class. For example, if you have SCUMember m("sukanya", "santa clara", "smanna@scu.edu"); Then you should test the methods like, a.change_address("Mountain View");... and so on and verify if the address has changed by printing it. V */
Student student("sukanya", "smanna@scu.edu", "OCB", "CS");
cout
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
