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 02:10
3. (5 points) describe what would be printed by the code below or what error would occur. const char* cstr = "0123456"; const char* ptr = & cstr[4]; cout < < ptr[-1] < < ptr < < endl; 1 4. (5 points) theseus has been trapped in a maze with a minotaur, which is trying to capture him. each round, theseus and the minotaur move through the maze; theseus towards the exit, and the minotaur towards theseus. theseus can move in any of the four cardinal directions, or he can wait for a round to see how the minotaur moves. write code that creates a data type to represent the possible moves that theseus could make.
Answers: 3
question
Computers and Technology, 22.06.2019 17:30
Under which key category do the page up and page down keys fall? page up and page down keys fall under the keys category.
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
Facial expressions and gestures are examples of messages.
Answers: 3
question
Computers and Technology, 23.06.2019 19:30
Anul 2017 tocmai s-a încheiat, suntem trişti deoarece era număr prim, însă avem şi o veste bună, anul 2018 este produs de două numere prime, 2 şi 1009. dorel, un adevărat colecţionar de numere prime, şi-a pus întrebarea: “câte numere dintr-un interval [a,b] se pot scrie ca produs de două numere prime? “.
Answers: 3
You know the right answer?
Write the PrintItem() function for the base class. Sample output for below program:

Las...
Questions
question
Mathematics, 28.10.2020 18:50
question
Mathematics, 28.10.2020 18:50
question
Mathematics, 28.10.2020 18:50
question
Mathematics, 28.10.2020 18:50
Questions on the website: 13722359