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
Get step-by-step solutions from verified subject matter experts
