#include <iostream>
#include <cmath>

class Power {
public:
    virtual double calculatePower(double base, int exponent) = 0;
};

class NumberPower : public Power {
public:
    double calculatePower(double base, int exponent) override {
        return pow(base, exponent);
    }
};

int main() {
    NumberPower powerObj; // Creating object of NumberPower class

    double base;
    int exponent;

    std::cout << "Enter the base number: ";
    std::cin >> base;

    std::cout << "Enter the exponent: ";
    std::cin >> exponent;

    double result = powerObj.calculatePower(base, exponent);

    std::cout << base << " raised to the power of " << exponent << " is: " << result << std::endl;

    return 0;
}


Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: