Question: USING C++ Create a class named Monster with private variables name and health. The name always has to be provided when creating a Monster object.

USING C++

Create a class named Monster with private variables name and health. The name always has to be provided when creating a Monster object. The default health for a Monster is 100, but a Monster object can be created with any health value.

Afterwards, Write the operator<< (the insertion operator) for Monster, so the following code provides the given output exactly as provided. If any changes are required to the Monster class, state them.

Monster p("Pennywise"); Monster r("Rodan", 1000); cout << p << endl; cout << r << endl;

Output:

 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!