subject
Computers and Technology, 24.04.2020 15:45 yfnal3x

Write the PrintItem() function for the base class. Sample output for below program:

Last name: Smith
First and last name: Bill Jones

#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() const override {
cout << "First and last name: ";
cout << firstName << " " << lastName << endl;
};
private:
string firstName;
};
int main() {
BaseItem* baseItemPtr = nullptr;
DerivedItem* derivedItemPtr = nullptr;
vector itemList;
unsigned int i; baseItemPtr = new BaseItem();
baseItemPtr->SetLastName("Smith" );
derivedItemPtr = new DerivedItem();
derivedItemPtr->SetLastName("Jon es");
derivedItemPtr->SetFirstName("Bi ll"); itemList. push_back(baseItemPtr); itemList. push_back(derivedItemPtr);
for (i = 0; i < itemList. size(); ++i) {
itemList. at(i)->PrintItem();
}
return 0;
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 19:00
If your accelerator suddenly gets stuck what should you do
Answers: 2
question
Computers and Technology, 23.06.2019 00:30
Quick pl which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
question
Computers and Technology, 23.06.2019 17:00
*! 20 points! *jeff wants to create a website with interactive and dynamic content. which programming language will he use? a. dhtml b. html c. css d. javascript
Answers: 1
question
Computers and Technology, 24.06.2019 02:20
Peter is thinking of a number which isless than 50. the number has 9 factors.when he adds 4 to the number, itbecomes a multiple of 5. what is thenumber he is thinking of ?
Answers: 1
You know the right answer?
Write the PrintItem() function for the base class. Sample output for below program:

Las...
Questions
question
Mathematics, 12.12.2020 17:00
question
Health, 12.12.2020 17:00
question
Mathematics, 12.12.2020 17:00
question
Spanish, 12.12.2020 17:00
Questions on the website: 13722361