Create a one (1) program that will apply all polymorphism techniques such as function, runtime and operator overloading.
#include <iostream>
using namespace std;
class Human{
    public:
        int power;
    
        Human(int n){
            power = n;
        }
        Human operator +(Human const &obj){
            Human combined(100);
            combined.power=power+obj.power;
            return combined;
        }
        
        virtual void scream(){
            for(int i=0; i<power;i++)
                cout<<"A";
            cout<<endl;
        }
        void scream(int n){
            for(int i=0; i<n;i++)   
                cout<<"A";
            cout<<endl;
        }
};
class Child: public Human{
    void scream(){
        cout<<"aaaaaa"<<endl;
    }
};
int main()
{
    Human me(10), you(5);
    me.scream();
    me.scream(2);
    Human mutant = me+you;
    mutant.scream();
    
    return 0;
}
Comments