Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include using namespace std; //class inteface for template, Holder template class Holder { T data; public: void dataInput(); void dataOutput(); }; //Class implementation for

image text in transcribed
#include

#include

using namespace std;

//class inteface for template, Holder

template

class Holder

{

T data;

public:

void dataInput();

void dataOutput();

};

//Class implementation for class template, Holder

template

void Holder ::dataInput()

{

cout

cin>>data;

}

template

void Holder::dataOutput()

{

cout

cout

}

//Class Interfaces for Item and Food

class Item

{

private:

int num;

double price;

public:

friend ostream& operator

friend istream& operator>>(istream&, Item&);

};

class Food

{

private:

int fatGrams;

int calories;


public:

friend ostream& operator

friend istream& operator>>(istream&, Food&);

};

int main()

{

Holder num;

Holder anItem;

Holder goody;

cout

num.dataInput();

cout

anItem.dataInput();

cout

goody.dataInput();

cout

num.dataOutput();

cout

anItem.dataOutput();

goody.dataOutput();

return 0;

}

//Class Implementation for Item and Food

ostream& operator

{

out

return out;

}

istream& operator>>(istream& in, Item& a)

{

cout

in >> a.num;

cout

in >> a.price;

return in;

}

ostream& operator

{

out

return out;

}

istream& operator>>(istream& in, Food& a)

{

cout

in >> a.fatGrams;

cout

in >> a.calories;

return in;

}
Compare output A Output differs. See highlights below. Special character legend 439175 11935574 Input 119.49 62 1024 nt? Your output ends with Here's the data you requested: 4 Here's the data you requested:11935574 $119.49 Here's the data you requested:62grams fat1024calories Here's the data you requested: 439175 39175 Expected output Here's the data you requested: 11935574 $119.49 ends with Here's the data you requested:62 grams fat 1024 caloriest

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Ai And The Lottery Defying Odds With Intelligent Prediction

Authors: Gary Covella Ph D

1st Edition

B0CND1ZB98, 979-8223302568

More Books

Students also viewed these Databases questions

Question

design a simple performance appraisal system

Answered: 1 week ago