Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// Code given #include #include #include using namespace std; // parent or base class class SCUMember { public: SCUMember(const string& name, const string& email, const

image text in transcribed
// 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
*/
Student student("sukanya", "smanna@scu.edu", "OCB", "CS");
cout
return 0;
}
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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

Students also viewed these Databases questions

Question

Evaluate 3x - x for x = -2 Answer:

Answered: 1 week ago

Question

What is group replacement? Explain with an example. (2-3 lines)

Answered: 1 week ago