Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help in C++ class Person { // this is the base class private: string name; int idNumber; public: void print(); string getName(); }; class Student

Help in C++

image text in transcribedimage text in transcribed

class Person { // this is the base class private: string name; int idNumber; public: void print(); string getName(); };

class Student : public Person { // this class inherits from the base class Person private: string major; int gradYear; public: void print(); void changeMajor(const string& newMajor); }; void Person::print() { cout

Person person("Mary", 12345); // declare a Person Student student("Bob", 98764, "Math", 2018); // declare a Student cout

Person* pp[100]; // array of 100 Person pointers pp[0] = new Person(); // declare a Person pp[1] = new Student(); // declare a Student cout getName() print(); // invokes Person.print() pp[1]->print(); // also invokes Person.print() pp[1]->changeMajor("Physics"); // ERROR!

virtual void Person::print() { // ... } virtual void Student::print() { // ... }

Person* pp[100]; // array of 100 Person pointers pp[0] = new Person(); // declare a Person pp[1] = new Student(); // declare a Student pp[0]->print(); // invokes Person.print() pp[1]->print(); // invokes Student.print()

I have included the person-student class which needs to be modified. Please comment code and write in C++.

2. Programming exercise. Generalize the Person-Student class hierarchy to include classes Faculty, UndergraduateStudent, GraduateStudent, Professor, Instructor. Clearly show the inheritance structure of these classes. Propose some appropriate member variables for each class. (20 pts.)

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

=+ How do some of them single you out when you're the consumer?

Answered: 1 week ago