Question: you have to complete this code #include using namespace std; class Hero { int power; public: ostream& display() { cout < < power; return cout;}

you have to complete this code

#include

using namespace std;

class Hero {

int power;

public:

ostream& display() { cout << power; return cout;}

Hero() { power = 0;}

Hero(int p) { power = p; }

//Implementation should be done within the class

};

int main() {

Hero Hulk(100);

Hero Flash = int(Hulk); //overload int typecast

Flash.display()<< endl;

Hero Thor= Hulk++; //overload postfix increment operator

//Thor will have the same power of Hulk

// before increase.

Hulk.display()<

}

Implement the following member functions

a) Overload the int typecast. b) Overload the unary postfix increment operator.

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!