Computers and Technology
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
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 20:30, summerhumphries3
What are some settings you can control when formatting columns?
Answers: 1
image
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
Computers and Technology, 25.06.2019 00:30, marziel24
Which type of cell references are locked and not automatically updated when it’s copied a)formula b)relative c)absolute d)worksheet
Answers: 1
image
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?
Write the PrintItem() function for the base class. Sample output for below program:

Las...

Questions in other subjects:

Konu
Mathematics, 05.07.2019 05:30