Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

struct Item { Item(std::string name, int magic=0) : name{name}, magic{magic} {} std::string name; /// Item name int magic = 0; /// Amount of magic the

struct Item { Item(std::string name, int magic=0) : name{name}, magic{magic} {} std::string name; /// Item name int magic = 0; /// Amount of "magic" the item is imbued with std::ostream& write( std::ostream& fout ) const; }; std::ostream& operator<<( std::ostream& fout, const Item& item );

Implement the write() method and the overloaded stream insertion operator in the Item.cpp file.

The write() method should display the name (in a 30 character block), and magic value of a game item, with a space between them. Write this method now, using iomanips setiosflags(std::ios::left) to left justify the strings and resetiosflags(std::ios::left) to undo the justification after use. The write() method should return the stream after using it. The overloaded operator << simply calls write(); complete this function as well.

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

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

Did Tims have an insurable interest in the building?

Answered: 1 week ago