Question: In C++ (note that none of the exisiting code can be modified. Solution must simply be added to the existing code) #include #include #include using

In C++ (note that none of the exisiting code can be modified. Solution must simply be added to the existing code)

In C++ (note that none of the exisiting code can be modified.

#include #include #include using namespace std;

class BaseItem { public: void SetLastName(string providedName) { lastName = providedName; };

// FIXME: Define PrintItem() member function

/* Your solution goes here */

protected: string lastName; };

class DerivedItem : public BaseItem { public: void SetFirstName(string providedName) { firstName = providedName; };

void PrintItem() { cout

private: string firstName; };

int main() { BaseItem* baseItemPtr = nullptr; DerivedItem* derivedItemPtr = nullptr; vector itemList; int i;

baseItemPtr = new BaseItem(); baseItemPtr->SetLastName("Smith");

derivedItemPtr = new DerivedItem(); derivedItemPtr->SetLastName("Jones"); derivedItemPtr->SetFirstName("Bill");

itemList.push_back(baseItemPtr); itemList.push_back(derivedItemPtr);

for (i = 0; i PrintItem(); }

return 0; }

Write the Printltem function for the base class. Sample output for below program: Last name: Smith First and last name: Bill Jones

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!