subject

Implementing the following object oriented programming constructions.1. Member FunctionsReplace the eight supporting output functions with member functions in the eight struct s. Name the functions as you like, but name them all the same. Their prototypes inside the structs should all look exactly alike, all with exactly one parameter -- an ostream reference. Modify the function called from the console and file output loops in int main accordingly.2. Stream ManipulatorsReplace the formatting code blocks in each output function with the manipulators provided in the module.3. Conditional OperatorsIf you have not already done so, apply the conditional operator so that there are no more if-else statements to convert tokens to dimensions.#include#include#include #include#include#include#include#in cludeusing namespace std;struct Square{ double side;};void outputSquare(ostream&, const Square&);struct Rectangle{ double length; double width;};void outputRectangle(ostream&, const Rectangle&);struct Circle{ double radius;};void outputCircle(ostream&, const Circle&);struct Triangle{ double side;};void outputTriangle(ostream&, const Triangle&);struct Cube{ double side;};void outputCube(ostream&, const Cube&);struct Box{ double length; double width; double height;};void outputBox(ostream&, const Box&);struct Cylinder{ double radius; double height;};void outputCylinder(ostream&, const Cylinder&);struct Prism{ double side; double height;};void outputPrism(ostream&, const Prism&);vector parseString(string);int main(){ ifstream infile("Shapes. input. txt"); ofstream fout; fout. open("Shapes. output. txt"); vector bag; vector bagType; string str; vector tokens; while (!infile. eof()) { getline(infile, str); tokens = parseString(str); if (tokens. size() != 0) { if (tokens[0] == "SQUARE") { Square* s = new Square(); if (tokens. size() > 1) s->side = atof(tokens[1].c_str()); else s->side = 0; bag. push_back(s); bagType. push_back(1);}//there's way more shapes, I just had to cut it out to make this question shorter else { if (tokens[0] == "EOF") continue; cout << tokens[0] << " Invalid Object" << endl; } } } for (unsigned int i = 0; i < bag. size(); i++) { if (bagType[i] == 1) { Square* xSquare = reinterpret_cast(bag[i]); Square& ySquare = *xSquare; outputSquare(cout, ySquare); } }//there's way more shapes, I just had to cut it out to make this question shorter for (unsigned int i = 0; i < bag. size(); i++) { if (bagType[i] == 1) { Square* xSquare = reinterpret_cast(bag[i]); Square& ySquare = *xSquare; outputSquare(fout, ySquare); } }//there's way more shapes, I just had to cut it out to make this question shorter for (unsigned int i = 0; i < bag. size(); i++) { if (bagType[i] == 1) { Square* xSquare = reinterpret_cast(bag[i]); delete xSquare; } }//there's way more shapes, I just had to cut it out to make this question shorter fout. close(); return 0;}vector parseString(string str){ stringstream s(str); istream_iterator begin(s), end; return vector(begin, end);}void outputSquare(ostream& fout, const Square& s){ double area, perimeter; area = s. side * s. side; perimeter = 4 * s. side; fout << "SQUARE side = " << s. side << " area = " << fixed << setprecision(2) << area << " perimeter = " << fixed << setprecision(2) << perimeter << "\n";}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 17:30
Scientists have changed the model of the atom as they have gathered new evidence. one of the atomic models is shown below. what experimental evidence led to the development of this atomic model from the one before it? a few of the positive particles aimed at a gold foil seemed to bounce back. the colors of light emitted from heated atoms had very specific energies. experiments with water vapor showed that elements combine in specific proportions. cathode rays were bent in the same way whenever a magnet was brought near them.
Answers: 2
question
Computers and Technology, 24.06.2019 12:00
Jack is assisting his younger sibling mary with her mathematics assignment, which includes a study of the number system. jack explains to mary that whole numbers are counting numbers that could be used to record the number of fruits in a basket. which data type represents whole numbers? a.integers.b.floating-point numbers. c.strings.d.boolean
Answers: 1
question
Computers and Technology, 25.06.2019 06:00
In 2 to 3 sentences, describe how you would change the background of a group of cells
Answers: 1
question
Computers and Technology, 25.06.2019 08:20
With technology, information is sent to users based on their previous inquiries, interests, or specifications.
Answers: 2
You know the right answer?
Implementing the following object oriented programming constructions.1. Member FunctionsReplace the...
Questions
question
Computers and Technology, 17.08.2020 04:01
question
Mathematics, 17.08.2020 04:01
question
Mathematics, 17.08.2020 04:01
question
Chemistry, 17.08.2020 04:01
question
Mathematics, 17.08.2020 04:01
question
Social Studies, 17.08.2020 04:01
Questions on the website: 13722367