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)

#include
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
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
Get step-by-step solutions from verified subject matter experts
