Write the PrintItem() function for the base class. Sample output for below program:
Las...
![Computers and Technology](/tpl/images/cats/informatica.png)
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;
}
![answer](/tpl/images/cats/otvet.png)
Answers: 1
Other questions on the subject: Computers and Technology
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 20:30, summerhumphries3
What are some settings you can control when formatting columns?
Answers: 1
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 03:40, Eylul30
4. does the kernel phenotype distribution support the idea that the cob is the result of a dihybrid cross? what information supports your answer? if a dihybrid cross (i. e. f1 to f2 of standard mendelian crosses) is not indicated what conditions might contribute to this finding.
Answers: 2
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 25.06.2019 05:30, 19jcormier
You are asked to calculate an object's velocity, in order to do so you must know the object's a. direction and speed. b. distance and time. c. speed and distance. d. direction and distance.
Answers: 1
Do you know the correct answer?
Questions in other subjects:
![Konu](/tpl/images/cats/mat.png)
![Konu](/tpl/images/cats/mat.png)
Mathematics, 05.07.2019 05:30
![Konu](/tpl/images/cats/istoriya.png)
![Konu](/tpl/images/cats/obshestvoznanie.png)
![Konu](/tpl/images/cats/himiya.png)
Chemistry, 05.07.2019 05:30
![Konu](/tpl/images/cats/mat.png)
Mathematics, 05.07.2019 05:30
![Konu](/tpl/images/cats/ekonomika.png)
![Konu](/tpl/images/cats/mat.png)
Mathematics, 05.07.2019 05:30
![Konu](/tpl/images/cats/obshestvoznanie.png)
![Konu](/tpl/images/cats/biologiya.png)
Biology, 05.07.2019 05:30