Question: Please help me fix my code. It won't print the names. C++ class Person { public: Person(); Person(string input_name, int input_age); string get_input_name() { return

Please help me fix my code. It won't print the names. C++

Please help me fix my code. It won't print the names. C++

class Person

{

public:

Person();

Person(string input_name, int input_age);

string get_input_name() { return name;}

int get_input_age() { return age;}

virtual void print() const {

cout

}

protected:

string name;

int age;

};

class Student : public Person

{

public:

Student();

Student(string input_name, int input_age, string input_college) :

Person(input_name, input_age) { }

string get_input_college() const { return college;}

virtual void print() {

cout

}

protected:

string college;

};

int main () {

vector everybody(3);

everybody[0] = new Person("Monica", 18);

everybody[1] = new Student( "Ross", 20, "NYU");

everybody[2] = new Student("Rachel", 19, "UCLA");

for ( int n = 1 ; n

everybody[n]->print();

return 0; }

(c) (5 points) Consider the base class Person and its derived class Student. Complete the portion of the code that is missing and correct errors so that the code compiles. L.e. implement the constructors and the member function print such that all the member fields of the objects are printed using polymorphism. class Person public: Person); Person (string input_name, int input_age); rivate: string name; int age; t; class Student : public Person public: Student O; Student (string input_ name, int input_age, string input college) private string college int main() vector everybody (3); everybody [O] new Person( 'Monic'", 18); everybody [1] = new Student( Ross,, , 20, ("NYU"); everybody [2] - new Student( Rachel'', 19, UCLA') for ( n = 1 ; n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!